timezone added in friendrequest

master
Bhaskara Kishore 2 years ago
parent b0b2e7beac
commit 342e5708d6

11
node_modules/.package-lock.json generated vendored

@ -6846,6 +6846,17 @@
"node": "*" "node": "*"
} }
}, },
"node_modules/moment-timezone": {
"version": "0.5.43",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz",
"integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==",
"dependencies": {
"moment": "^2.29.4"
},
"engines": {
"node": "*"
}
},
"node_modules/mongodb": { "node_modules/mongodb": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz",

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,64 @@
# [Moment Timezone](http://momentjs.com/timezone/)
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-download-url]
[![MIT License][license-image]][license-url]
[![Build Status][ci-image]][ci-url]
[![FOSSA Status][fossa-badge-image]][fossa-badge-url]
IANA Time zone support for Moment.js
## Project Status
Moment-Timezone is an add-on for Moment.js. Both are considered legacy projects, now in maintenance mode. In most cases, you should choose a different library.
For more details and recommendations, please see [Project Status](https://momentjs.com/docs/#/-project-status/) in the Moment docs.
*Thank you.*
## Resources
- [Documentation](https://momentjs.com/timezone/docs/)
- [Changelog](changelog.md)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/moment-timezone)
## Examples
```js
var june = moment("2014-06-01T12:00:00Z");
june.tz('America/Los_Angeles').format('ha z'); // 5am PDT
june.tz('America/New_York').format('ha z'); // 8am EDT
june.tz('Asia/Tokyo').format('ha z'); // 9pm JST
june.tz('Australia/Sydney').format('ha z'); // 10pm EST
var dec = moment("2014-12-01T12:00:00Z");
dec.tz('America/Los_Angeles').format('ha z'); // 4am PST
dec.tz('America/New_York').format('ha z'); // 7am EST
dec.tz('Asia/Tokyo').format('ha z'); // 9pm JST
dec.tz('Australia/Sydney').format('ha z'); // 11pm EST
```
## License
Moment-timezone is freely distributable under the terms of the [MIT license][license-url].
[![FOSSA Status][fossa-large-image]][fossa-large-url]
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE
[npm-url]: https://npmjs.org/package/moment-timezone
[npm-version-image]: https://img.shields.io/npm/v/moment-timezone.svg?style=flat
[npm-downloads-image]: https://img.shields.io/npm/dm/moment-timezone.svg?style=flat
[npm-download-url]: https://npmcharts.com/compare/moment-timezone?minimal=true
[ci-url]: https://github.com/moment/moment-timezone/actions/workflows/tests.yml?query=branch%253Adevelop
[ci-image]: https://github.com/moment/moment-timezone/actions/workflows/tests.yml/badge.svg?query=branch%253Adevelop
[fossa-badge-image]: https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmoment%2Fmoment-timezone.svg?type=shield
[fossa-badge-url]: https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmoment%2Fmoment-timezone?ref=badge_shield
[fossa-large-image]: https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmoment%2Fmoment-timezone.svg?type=large
[fossa-large-url]: https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmoment%2Fmoment-timezone?ref=badge_large

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,263 @@
### `0.5.43` _2023-03-31_
* Updated data to IANA TZDB `2023c`
### `0.5.42` _2023-03-24_
* Updated data to IANA TZDB `2023b`
### `0.5.41` _2023-02-25_
* Updated `moment` npm dependency to `2.29.4` to remove automated warnings about insecure dependencies.
Moment Timezone still works with core Moment `2.9.0` and higher.
* Updated all dev dependencies including UglifyJS, which produces the minified builds.
* Added deprecation warning to the pre-built `moment-timezone-with-data-2012-2022` bundles [#1035](https://github.com/moment/moment-timezone/issues/1035).
Use the rolling `moment-timezone-with-data-10-year-range` files instead.
### `0.5.40` _2022-12-11_
* Updated data to IANA TZDB `2022g`
### `0.5.39` _2022-11-13_
* Updated data to IANA TZDB `2022f`
### `0.5.38` _2022-10-15_
* Updated data to IANA TZDB `2022e`
* Added `moment.tz.dataVersion` property to TypeScript definitions [#930](https://github.com/moment/moment-timezone/issues/930)
* Removed temporary `.tar.gz` files from npm releases [#1000](https://github.com/moment/moment-timezone/pull/1000)
### `0.5.37` _2022-08-25_
* Re-publish npm package, because of extra folder present in 0.5.36, check
https://github.com/moment/moment-timezone/issues/999
### `0.5.36` _2022-08-25_
* IANA TZDB 2022c
* improvements/fixes to data pipeline
### `0.5.35` _2022-08-23_
* Fix command injection in data pipeline https://github.com/moment/moment-timezone/security/advisories/GHSA-56x4-j7p9-fcf9
* Fix cleartext transmission of sensitive information https://github.com/moment/moment-timezone/security/advisories/GHSA-v78c-4p63-2j6c
Thanks to the OpenSSF Alpha-Omega project for reporting these!
### `0.5.34` _2021-11-10_
* Updated data to IANA TZDB `2021e`
### `0.5.33` _2021-02-06_
* Updated data to IANA TZDB `2021a`
### `0.5.32` _2020-11-14_
* Updated data to IANA TZDB `2020d`
### `0.5.31` _2020-05-16_
* Fixed Travis builds for Node.js 4 and 6
### `0.5.30` _2020-05-16_
* Updated data to IANA TZDB `2020a`
* Fixed typescript definitions
NOTE: You might need to un-install @types/moment-timezone. Check
https://github.com/moment/moment-timezone/issues/858 for more info
### `0.5.29` _2020-05-16_
* Merged fix of es6 module loading issue https://github.com/moment/moment-timezone/commit/1fd42349189b24e15c60f162dc8c40b42db79dfe
* Merged PR with typescript declarations https://github.com/moment/moment-timezone/commit/ed529ea6fbcc70315c0c3f6d7c7cb70eadf56b03
* Merged fixes to changelog https://github.com/moment/moment-timezone/commit/adb7d7b43c7328d814311ac1355bfeef88eab6e8
### `0.5.28` _2020-02-21_
Merged pull request #410 from @adgrace:
* Added a method `moment.tz.zonesForCountry(country_code)` which returns all timezones for the country
* Added a method `moment.tz(timezone_id).countries()` to get countries for some time zone
* Added a method `moment.tz.countries()` to get all country codes
* And as you know `moment.tz.zones()` already exists
### `0.5.27` _2019-10-14_
* Updated data to IANA TZDB `2019c`
### `0.5.26` _2019-06-06_
* Updated data to IANA TZDB `2019b`
* Fix: stabilize Array.sort [#762](https://github.com/moment/moment-timezone/pull/762)
### `0.5.25` _2019-04-17_
* Fix `moment.tz.dataVersion` to return `2019a` [#742](https://github.com/moment/moment-timezone/issues/742)
* Update path in bower.json
### `0.5.24` _2019-04-17_
* Updated data to IANA TZDB `2019a` [#737](https://github.com/moment/moment-timezone/issues/737)
* Start shipping both a 1970-1930 file and a rolling 10-year file [#614](https://github.com/moment/moment-timezone/issues/614) [#697](https://github.com/moment/moment-timezone/issues/697)
* Fixed bug where `_z` time zone name was not cleared with `.local()` or `.utcOffset(offset)` [#738](https://github.com/moment/moment-timezone/issues/738)
### `0.5.23` _2018-10-28_
* Fix minor issue with tz guessing in Russia [#691](https://github.com/moment/moment-timezone/pull/691)
### `0.5.22` _2018-10-28_
* Updated data to IANA TZDB `2018g` [#689](https://github.com/moment/moment-timezone/pull/689)
* Fix issue with missing LMT entries for some zones, and fix data builds on Linux and Windows [#308](https://github.com/moment/moment-timezone/issues/308)
### `0.5.21` _2018-06-23_
* Bugfix: revert breaking change introduced in 0.5.18
### `0.5.20` _2018-06-18_
* Bugfix: accidentally commented code
### `0.5.19` _2018-06-18_
* Revert: moved moment to peerDependencies
### `0.5.18` _2018-06-18_
* Return error when timezone name is not a string.
* Moved moment to peerDependencies [#628](https://github.com/moment/moment-timezone/pull/628)
* Prefer nodejs to amd declaration [#573](https://github.com/moment/moment-timezone/pull/573)
### `0.5.17` _2018-05-12_
* Updated data to IANA TZDB `2018d`. [#616](https://github.com/moment/moment-timezone/pull/616)
### `0.5.16` _2018-04-18_
* Fixed Etc/UTC timezone recognition, updated tests. [#599](https://github.com/moment/moment-timezone/pull/599)
* Updated minified files to contain IANA TZDB `2018d` data
### `0.5.15` _2018-04-17_
* Updated data to IANA TZDB `2018d`. [#596](https://github.com/moment/moment-timezone/pull/596)
### `0.5.14` _2017-10-30_
* Ensure Intl response is valid when guessing time zone. [#553](https://github.com/moment/moment-timezone/pull/553)
* Updated data to IANA TZDB `2017c`. [#552](https://github.com/moment/moment-timezone/pull/552)
* Convert to tz keeping wall time [#505](https://github.com/moment/moment-timezone/pull/505)
* Make all time zones available for guessing. [#483](https://github.com/moment/moment-timezone/pull/483)
* zone.offset has been deprecated in favor of zone.utcOffset [#398](https://github.com/moment/moment-timezone/pull/398)
* Check for timestamp formats when parsing [#348](https://github.com/moment/moment-timezone/pull/348)
### `0.5.13` _2017-04-04_
* Bumped version to address Bower cache issues with last release. [#474](https://github.com/moment/moment-timezone/issues/474)
* (No actual changes otherwise)
### `0.5.12` _2017-04-02_
* Updated data to IANA TZDB `2017b`. [#422](https://github.com/moment/moment-timezone/pull/460)
* Build the truncated data file as 2012-2022 (+/- 5 years).
### `0.5.11` _2016-12-23_
* Remove log statement when data is loaded twice. [#352](https://github.com/moment/moment-timezone/pull/352)
### `0.5.10` _2016-11-27_
* Updated data to IANA TZDB `2016j`. [#422](https://github.com/moment/moment-timezone/pull/422)
### `0.5.9` _2016-11-03_
* Fixed the output of `moment.tz.version`. [#413](https://github.com/moment/moment-timezone/issues/413)
### `0.5.8` _2016-11-03_
* Updated data to IANA TZDB `2016i`. [#411](https://github.com/moment/moment-timezone/pull/411)
### `0.5.7` _2016-10-21_
* Updated data to IANA TZDB `2016h`. [#403](https://github.com/moment/moment-timezone/pull/403)
### `0.5.6` _2016-10-08_
* Updated data to IANA TZDB `2016g`. [#394](https://github.com/moment/moment-timezone/pull/394)
### `0.5.5` _2016-07-24_
* Updated data to IANA TZDB `2016f`. [#360](https://github.com/moment/moment-timezone/pull/360)
### `0.5.4` _2016-05-03_
* Updated data to IANA TZDB `2016d`. [#336](https://github.com/moment/moment-timezone/pull/336)
* Ignore the results from `Intl.DateTimeFormat().resolvedOptions().timeZone` if it is undefined. [#322](https://github.com/moment/moment-timezone/pull/322)
### `0.5.3` _2016-03-24_
* Updated data to IANA TZDB `2016c`. [#321](https://github.com/moment/moment-timezone/pull/321)
### `0.5.2` _2016-03-15_
* Updated data to IANA TZDB `2016b`. [#315](https://github.com/moment/moment-timezone/pull/315)
### `0.5.1` _2016-03-01_
* Updated data to IANA TZDB `2016a`. [#299](https://github.com/moment/moment-timezone/pull/299)
* Fixed bug when `Date#toTimeString` did not return a known format. [#302](https://github.com/moment/moment-timezone/pull/302) [#303](https://github.com/moment/moment-timezone/pull/303)
* Added lookup on `Intl.DateTimeFormat().resolvedOptions().timeZone` to `moment.tz.guess()`. [#304](https://github.com/moment/moment-timezone/pull/304) [#291](https://github.com/moment/moment-timezone/pull/291)
### `0.5.0` _2015-12-28_
* Added support for guessing the user's timezone via `moment.tz.guess()`. [#285](https://github.com/moment/moment-timezone/pull/285)
* Fixed UMD export issue when there was an html element with `id=exports`. [#275](https://github.com/moment/moment-timezone/pull/275)
* Removed jspm specific dependencies from `package.json`. [#284](https://github.com/moment/moment-timezone/pull/284)
### `0.4.1` _2015-10-07_
* Updated data to IANA TZDB `2015e`. [#253](https://github.com/moment/moment-timezone/pull/253)
* Updated data to IANA TZDB `2015f`. [#253](https://github.com/moment/moment-timezone/pull/253)
* Updated data to IANA TZDB `2015g`. [#255](https://github.com/moment/moment-timezone/pull/255)
* Added jspm dependencies for moment. [#234](https://github.com/moment/moment-timezone/pull/234)
* Included builds directory in npm. [#237](https://github.com/moment/moment-timezone/pull/237)
* Removed version field from bower.json. [#230](https://github.com/moment/moment-timezone/pull/230)
### `0.4.0` _2015-05-30_
* Updated data to IANA TZDB `2015b`. [#201](https://github.com/moment/moment-timezone/pull/201)
* Updated data to IANA TZDB `2015c`. [#214](https://github.com/moment/moment-timezone/pull/214)
* Updated data to IANA TZDB `2015d`. [#214](https://github.com/moment/moment-timezone/pull/214)
* Updated zone getter to allow lazy unpacking to improve initial page load times. [#216](https://github.com/moment/moment-timezone/pull/216)
* Added a `package.json` `jspm:main` entry point. [#194](https://github.com/moment/moment-timezone/pull/194)
* Added `composer.json`. [#222](https://github.com/moment/moment-timezone/pull/222)
* Added an error message when trying to load moment-timezone twice. [#212](https://github.com/moment/moment-timezone/pull/212)
### `0.3.1` _2015-03-16_
* Updated data to IANA TZDB `2015a`. [#183](https://github.com/moment/moment-timezone/pull/183)
### `0.3.0` _2015-01-13_
* *Breaking:* Added country data to the `meta/*.json` files. Restructured the data to support multiple countries per zone. [#162](https://github.com/moment/moment-timezone/pull/162)
* Added the ability to set a default timezone for all new moments. [#152](https://github.com/moment/moment-timezone/pull/152)
* Fixed a bug when passing a moment with an offset to `moment.tz`. [#169](https://github.com/moment/moment-timezone/pull/169)
* Fixed a deprecation in moment core, changing `moment#zone` to `moment#utcOffset`. [#168](https://github.com/moment/moment-timezone/pull/168)
### `0.2.5` _2014-11-12_
* Updated data to IANA TZDB `2014j`. [#151](https://github.com/moment/moment-timezone/pull/151)
### `0.2.4` _2014-10-20_
* Updated data to IANA TZDB `2014i`. [#142](https://github.com/moment/moment-timezone/pull/142)
### `0.2.3` _2014-10-20_
* Updated data to IANA TZDB `2014h`. [#141](https://github.com/moment/moment-timezone/pull/141)
### `0.2.2` _2014-09-04_
* Updated data to IANA TZDB `2014g`. [#126](https://github.com/moment/moment-timezone/pull/126)
* Added a warning when using `moment-timezone` with `moment<2.6.0`.
### `0.2.1` _2014-08-02_
* Fixed support for `moment@2.8.1+`.
### `0.2.0` _2014-07-21_
* Added the ability to configure whether ambiguous or invalid input is rolled forward or backward. [#101](https://github.com/moment/moment-timezone/pull/101)
* Added `moment>=2.6.0` as a dependency in `bower.json`. [#107](https://github.com/moment/moment-timezone/issues/107)
* Fixed getting the name of a zone that was added as a linked zone. [#104](https://github.com/moment/moment-timezone/pull/104)
* Added an error message when a zone was not loaded. [#106](https://github.com/moment/moment-timezone/issues/106)
### `0.1.0` _2014-06-23_
* *Breaking:* Changed data format from Zones+Rules to just Zones. [#82](https://github.com/moment/moment-timezone/pull/82)
* *Breaking:* Removed `moment.tz.{addRule,addZone,zoneExists,zones}` as they are no longer relevant with the new data format.
* Made library 20x faster. [JSPerf results](http://jsperf.com/moment-timezone-0-1-0/2)
* Completely rewrote internals to support new data format.
* Updated the data collection process to get data directly from http://www.iana.org/time-zones.
* Updated data to IANA TZDB `2014e`.
* Updated `bower.json` to use a browser specific `main:` entry point.
* Added built files with included data.
* Added support for accurately parsing input around DST changes. [#93](https://github.com/moment/moment-timezone/pull/93)
* Added comprehensive documentation at [momentjs.com/timezone/docs/](http://momentjs.com/timezone/docs/).
* Added `moment.tz.link` for linking two identical zones.
* Added `moment.tz.zone` for getting a loaded zone.
* Added `moment.tz.load` for loading a bundled version of data from the IANA TZDB.
* Added `moment.tz.names` for getting the names of all the loaded timezones.
* Added `moment.tz.unpack` and `moment.tz.unpackBase60` for unpacking data.
* Added `moment-timezone-utils.js` for working with the packed and unpacked data.
* Fixed major memory leak. [#79](https://github.com/moment/moment-timezone/issues/79)
* Fixed global export to allow use in web workers. [#78](https://github.com/moment/moment-timezone/pull/78)
* Fixed global export in browser environments that define `window.module`. [#76](https://github.com/moment/moment-timezone/pull/76)
### `0.0.6` _2014-04-20_
* Fixed issue with preventing loading moment-timezone more than once. [#75](https://github.com/moment/moment-timezone/pull/75)
### `0.0.5` _2014-04-17_
* Improved performance with memoization. [#39](https://github.com/moment/moment-timezone/issues/39)
* Published only necessary files to npm. [#46](https://github.com/moment/moment-timezone/issues/46)
* Added better handling of timezones around DST. [#53](https://github.com/moment/moment-timezone/issues/53) [#61](https://github.com/moment/moment-timezone/issues/61) [#70](https://github.com/moment/moment-timezone/issues/70)
* Added Browserify support. [#41](https://github.com/moment/moment-timezone/issues/41)
* Added `moment.tz.zoneExists` [#73](https://github.com/moment/moment-timezone/issues/73)
* Fixed cloning moments with a timezone. [#71](https://github.com/moment/moment-timezone/issues/71)
* Prevent loading moment-timezone more than once. [#74](https://github.com/moment/moment-timezone/issues/74)
### `0.0.3` _2013-10-10_
* Added Bower support.
* Added support for newer versions of moment.
* Added support for constructing a moment with a string and zone.
* Added more links and timezone names in moment-timezone.json
### `0.0.1` _2013-07-17_
* Initial version.

@ -0,0 +1,43 @@
{
"name": "moment/moment-timezone",
"description": "Parse and display dates in any timezone",
"version": "0.5.43",
"keywords": [
"moment",
"date",
"time",
"timezone",
"olson",
"iana",
"zone",
"tz"
],
"homepage": "http://momentjs.com/timezone/",
"license": "MIT",
"support": {
"issues": "https://github.com/moment/moment-timezone/issues",
"source": "https://github.com/moment/moment-timezone"
},
"authors": [
{
"name": "Tim Wood",
"email": "washwithcare@gmail.com",
"homepage": "http://timwoodcreates.com/"
}
],
"type": "component",
"require": {
"robloach/component-installer": "*",
"moment/moment": ">=2.9.0"
},
"extra": {
"component": {
"scripts": [
"moment-timezone.js"
],
"files": [
"builds/*.js"
]
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -0,0 +1,78 @@
// Type definitions for moment-timezone.js 0.5
// Project: http://momentjs.com/timezone/
// Definitions by: Michel Salib <https://github.com/michelsalib>
// Alan Brazil Lins <https://github.com/alanblins>
// Agustin Carrasco <https://github.com/asermax>
// Borys Kupar <https://github.com/borys-kupar>
// Anthony Rainer <https://github.com/pristinesource>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Migrated here from DefinitelyTyped in release moment-timezone@0.5.30
import moment = require('moment');
declare module 'moment' {
interface MomentZone {
name: string;
abbrs: string[];
untils: number[];
offsets: number[];
population: number;
abbr(timestamp: number): string;
offset(timestamp: number): number;
utcOffset(timestamp: number): number;
parse(timestamp: number): number;
}
interface MomentZoneOffset {
name: string;
offset: number;
}
interface MomentTimezone {
(): moment.Moment;
(timezone: string): moment.Moment;
(date: number, timezone: string): moment.Moment;
(date: number[], timezone: string): moment.Moment;
(date: string, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, strict: boolean, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, language: string, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, language: string, strict: boolean, timezone: string): moment.Moment;
(date: Date, timezone: string): moment.Moment;
(date: moment.Moment, timezone: string): moment.Moment;
(date: any, timezone: string): moment.Moment;
zone(timezone: string): MomentZone | null;
add(packedZoneString: string): void;
add(packedZoneString: string[]): void;
link(packedLinkString: string): void;
link(packedLinkString: string[]): void;
load(data: { version: string; links: string[]; zones: string[] }): void;
names(): string[];
zonesForCountry<T extends true>(country: string, with_offset: T): T extends true ? MomentZoneOffset[] : never;
zonesForCountry<T extends false>(country: string, with_offset?: T): T extends false ? string[] : never;
zonesForCountry(country: string, with_offset?: boolean): MomentZoneOffset[] | string[];
countries(): string[];
guess(ignoreCache?: boolean): string;
setDefault(timezone?: string): Moment;
dataVersion: string;
}
interface Moment {
tz(): string | undefined;
tz(timezone: string, keepLocalTime?: boolean): moment.Moment;
zoneAbbr(): string;
zoneName(): string;
}
const tz: MomentTimezone;
}
// require("moment-timezone") === require("moment")
export = moment;

@ -0,0 +1,2 @@
var moment = module.exports = require("./moment-timezone");
moment.tz.load(require('./data/packed/latest.json'));

@ -0,0 +1,70 @@
import moment = require('moment');
import { MomentTimezone } from "./index";
declare module 'moment' {
/** Parsed / unpacked zone data. */
interface UnpackedZone {
/** The uniquely identifying name of the time zone. */
name: string;
/** zone abbreviations */
abbrs: Array<string>;
/** (measured in milliseconds) */
untils: Array<number | null>;
/** (measured in minutes) */
offsets: Array<number>;
}
/** Bundle of zone data and links for multiple timezones */
interface PackedZoneBundle {
version: string;
zones: Array<string>;
links: Array<string>;
}
/** Bundle of zone data and links for multiple timezones */
interface UnpackedZoneBundle {
version: string;
zones: Array<UnpackedZone>;
links: Array<string>;
}
/** extends MomentTimezone declared in index */
interface MomentTimezone {
/** Converts zone data in the unpacked format to the packed format. */
pack(unpackedObject: UnpackedZone): string;
/** Convert a base 10 number to a base 60 string. */
packBase60(input: number, precision?: number): string;
/** Create links out of two zones that share data.
* @returns A new ZoneBundle with duplicate zone data replaced by links
*/
createLinks(unlinked: UnpackedZoneBundle): PackedZoneBundle;
/**
* Filter out data for years outside a certain range.
* @return a new, filtered UnPackedZone object
*/
filterYears(unpackedZone: UnpackedZone, startYear: number, endYear: number): UnpackedZone;
/**
* Filter out data for years outside a certain range.
* @return a new, filtered UnPackedZone object
*/
filterYears(unpackedZone: UnpackedZone, startAndEndYear: number): UnpackedZone;
/**
* Combines packing, link creation, and subsetting of years into one simple interface.
* Pass in an unpacked bundle, start year, and end year and get a filtered, linked, packed bundle back.
*/
filterLinkPack(unpackedBundle: UnpackedZoneBundle, startYear: number, endYear: number): PackedZoneBundle;
/**
* Combines packing, link creation, and subsetting of years into one simple interface.
* Pass in an unpacked bundle, start year, and end year and get a filtered, linked, packed bundle back.
*/
filterLinkPack(unpackedBundle: UnpackedZoneBundle, startAndEndYear: number): PackedZoneBundle;
}
}
// require("moment-timezone") === require("moment")
export = moment;

@ -0,0 +1,339 @@
//! moment-timezone-utils.js
//! version : 0.5.43
//! Copyright (c) JS Foundation and other contributors
//! license : MIT
//! github.com/moment/moment-timezone
(function (root, factory) {
"use strict";
/*global define*/
if (typeof module === 'object' && module.exports) {
module.exports = factory(require('./')); // Node
} else if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else {
factory(root.moment); // Browser
}
}(this, function (moment) {
"use strict";
if (!moment.tz) {
throw new Error("moment-timezone-utils.js must be loaded after moment-timezone.js");
}
/************************************
Pack Base 60
************************************/
var BASE60 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX',
EPSILON = 0.000001; // Used to fix floating point rounding errors
function packBase60Fraction(fraction, precision) {
var buffer = '.',
output = '',
current;
while (precision > 0) {
precision -= 1;
fraction *= 60;
current = Math.floor(fraction + EPSILON);
buffer += BASE60[current];
fraction -= current;
// Only add buffer to output once we have a non-zero value.
// This makes '.000' output '', and '.100' output '.1'
if (current) {
output += buffer;
buffer = '';
}
}
return output;
}
function packBase60(number, precision) {
var output = '',
absolute = Math.abs(number),
whole = Math.floor(absolute),
fraction = packBase60Fraction(absolute - whole, Math.min(~~precision, 10));
while (whole > 0) {
output = BASE60[whole % 60] + output;
whole = Math.floor(whole / 60);
}
if (number < 0) {
output = '-' + output;
}
if (output && fraction) {
return output + fraction;
}
if (!fraction && output === '-') {
return '0';
}
return output || fraction || '0';
}
/************************************
Pack
************************************/
function packUntils(untils) {
var out = [],
last = 0,
i;
for (i = 0; i < untils.length - 1; i++) {
out[i] = packBase60(Math.round((untils[i] - last) / 1000) / 60, 1);
last = untils[i];
}
return out.join(' ');
}
function packAbbrsAndOffsets(source) {
var index = 0,
abbrs = [],
offsets = [],
indices = [],
map = {},
i, key;
for (i = 0; i < source.abbrs.length; i++) {
key = source.abbrs[i] + '|' + source.offsets[i];
if (map[key] === undefined) {
map[key] = index;
abbrs[index] = source.abbrs[i];
offsets[index] = packBase60(Math.round(source.offsets[i] * 60) / 60, 1);
index++;
}
indices[i] = packBase60(map[key], 0);
}
return abbrs.join(' ') + '|' + offsets.join(' ') + '|' + indices.join('');
}
function packPopulation (number) {
if (!number) {
return '';
}
if (number < 1000) {
return number;
}
var exponent = String(number | 0).length - 2;
var precision = Math.round(number / Math.pow(10, exponent));
return precision + 'e' + exponent;
}
function packCountries (countries) {
if (!countries) {
return '';
}
return countries.join(' ');
}
function validatePackData (source) {
if (!source.name) { throw new Error("Missing name"); }
if (!source.abbrs) { throw new Error("Missing abbrs"); }
if (!source.untils) { throw new Error("Missing untils"); }
if (!source.offsets) { throw new Error("Missing offsets"); }
if (
source.offsets.length !== source.untils.length ||
source.offsets.length !== source.abbrs.length
) {
throw new Error("Mismatched array lengths");
}
}
function pack (source) {
validatePackData(source);
return [
source.name, // 0 - timezone name
packAbbrsAndOffsets(source), // 1 - abbrs, 2 - offsets, 3 - indices
packUntils(source.untils), // 4 - untils
packPopulation(source.population) // 5 - population
].join('|');
}
function packCountry (source) {
return [
source.name,
source.zones.join(' '),
].join('|');
}
/************************************
Create Links
************************************/
function arraysAreEqual(a, b) {
var i;
if (a.length !== b.length) { return false; }
for (i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
function zonesAreEqual(a, b) {
return arraysAreEqual(a.offsets, b.offsets) && arraysAreEqual(a.abbrs, b.abbrs) && arraysAreEqual(a.untils, b.untils);
}
function findAndCreateLinks (input, output, links, groupLeaders) {
var i, j, a, b, group, foundGroup, groups = [];
for (i = 0; i < input.length; i++) {
foundGroup = false;
a = input[i];
for (j = 0; j < groups.length; j++) {
group = groups[j];
b = group[0];
if (zonesAreEqual(a, b)) {
if (a.population > b.population) {
group.unshift(a);
} else if (a.population === b.population && groupLeaders && groupLeaders[a.name]) {
group.unshift(a);
} else {
group.push(a);
}
foundGroup = true;
}
}
if (!foundGroup) {
groups.push([a]);
}
}
for (i = 0; i < groups.length; i++) {
group = groups[i];
output.push(group[0]);
for (j = 1; j < group.length; j++) {
links.push(group[0].name + '|' + group[j].name);
}
}
}
function createLinks (source, groupLeaders) {
var zones = [],
links = [];
if (source.links) {
links = source.links.slice();
}
findAndCreateLinks(source.zones, zones, links, groupLeaders);
return {
version : source.version,
zones : zones,
links : links.sort()
};
}
/************************************
Filter Years
************************************/
function findStartAndEndIndex (untils, start, end) {
var startI = 0,
endI = untils.length + 1,
untilYear,
i;
if (!end) {
end = start;
}
if (start > end) {
i = start;
start = end;
end = i;
}
for (i = 0; i < untils.length; i++) {
if (untils[i] == null) {
continue;
}
untilYear = new Date(untils[i]).getUTCFullYear();
if (untilYear < start) {
startI = i + 1;
}
if (untilYear > end) {
endI = Math.min(endI, i + 1);
}
}
return [startI, endI];
}
function filterYears (source, start, end) {
var slice = Array.prototype.slice,
indices = findStartAndEndIndex(source.untils, start, end),
untils = slice.apply(source.untils, indices);
untils[untils.length - 1] = null;
return {
name : source.name,
abbrs : slice.apply(source.abbrs, indices),
untils : untils,
offsets : slice.apply(source.offsets, indices),
population : source.population,
countries : source.countries
};
}
/************************************
Filter, Link, and Pack
************************************/
function filterLinkPack (input, start, end, groupLeaders) {
var i,
inputZones = input.zones,
outputZones = [],
output;
for (i = 0; i < inputZones.length; i++) {
outputZones[i] = filterYears(inputZones[i], start, end);
}
output = createLinks({
zones : outputZones,
links : input.links.slice(),
version : input.version
}, groupLeaders);
for (i = 0; i < output.zones.length; i++) {
output.zones[i] = pack(output.zones[i]);
}
output.countries = input.countries ? input.countries.map(function (unpacked) {
return packCountry(unpacked);
}) : [];
return output;
}
/************************************
Exports
************************************/
moment.tz.pack = pack;
moment.tz.packBase60 = packBase60;
moment.tz.createLinks = createLinks;
moment.tz.filterYears = filterYears;
moment.tz.filterLinkPack = filterLinkPack;
moment.tz.packCountry = packCountry;
return moment;
}));

@ -0,0 +1,696 @@
//! moment-timezone.js
//! version : 0.5.43
//! Copyright (c) JS Foundation and other contributors
//! license : MIT
//! github.com/moment/moment-timezone
(function (root, factory) {
"use strict";
/*global define*/
if (typeof module === 'object' && module.exports) {
module.exports = factory(require('moment')); // Node
} else if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else {
factory(root.moment); // Browser
}
}(this, function (moment) {
"use strict";
// Resolves es6 module loading issue
if (moment.version === undefined && moment.default) {
moment = moment.default;
}
// Do not load moment-timezone a second time.
// if (moment.tz !== undefined) {
// logError('Moment Timezone ' + moment.tz.version + ' was already loaded ' + (moment.tz.dataVersion ? 'with data from ' : 'without any data') + moment.tz.dataVersion);
// return moment;
// }
var VERSION = "0.5.43",
zones = {},
links = {},
countries = {},
names = {},
guesses = {},
cachedGuess;
if (!moment || typeof moment.version !== 'string') {
logError('Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/');
}
var momentVersion = moment.version.split('.'),
major = +momentVersion[0],
minor = +momentVersion[1];
// Moment.js version check
if (major < 2 || (major === 2 && minor < 6)) {
logError('Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js ' + moment.version + '. See momentjs.com');
}
/************************************
Unpacking
************************************/
function charCodeToInt(charCode) {
if (charCode > 96) {
return charCode - 87;
} else if (charCode > 64) {
return charCode - 29;
}
return charCode - 48;
}
function unpackBase60(string) {
var i = 0,
parts = string.split('.'),
whole = parts[0],
fractional = parts[1] || '',
multiplier = 1,
num,
out = 0,
sign = 1;
// handle negative numbers
if (string.charCodeAt(0) === 45) {
i = 1;
sign = -1;
}
// handle digits before the decimal
for (i; i < whole.length; i++) {
num = charCodeToInt(whole.charCodeAt(i));
out = 60 * out + num;
}
// handle digits after the decimal
for (i = 0; i < fractional.length; i++) {
multiplier = multiplier / 60;
num = charCodeToInt(fractional.charCodeAt(i));
out += num * multiplier;
}
return out * sign;
}
function arrayToInt (array) {
for (var i = 0; i < array.length; i++) {
array[i] = unpackBase60(array[i]);
}
}
function intToUntil (array, length) {
for (var i = 0; i < length; i++) {
array[i] = Math.round((array[i - 1] || 0) + (array[i] * 60000)); // minutes to milliseconds
}
array[length - 1] = Infinity;
}
function mapIndices (source, indices) {
var out = [], i;
for (i = 0; i < indices.length; i++) {
out[i] = source[indices[i]];
}
return out;
}
function unpack (string) {
var data = string.split('|'),
offsets = data[2].split(' '),
indices = data[3].split(''),
untils = data[4].split(' ');
arrayToInt(offsets);
arrayToInt(indices);
arrayToInt(untils);
intToUntil(untils, indices.length);
return {
name : data[0],
abbrs : mapIndices(data[1].split(' '), indices),
offsets : mapIndices(offsets, indices),
untils : untils,
population : data[5] | 0
};
}
/************************************
Zone object
************************************/
function Zone (packedString) {
if (packedString) {
this._set(unpack(packedString));
}
}
Zone.prototype = {
_set : function (unpacked) {
this.name = unpacked.name;
this.abbrs = unpacked.abbrs;
this.untils = unpacked.untils;
this.offsets = unpacked.offsets;
this.population = unpacked.population;
},
_index : function (timestamp) {
var target = +timestamp,
untils = this.untils,
i;
for (i = 0; i < untils.length; i++) {
if (target < untils[i]) {
return i;
}
}
},
countries : function () {
var zone_name = this.name;
return Object.keys(countries).filter(function (country_code) {
return countries[country_code].zones.indexOf(zone_name) !== -1;
});
},
parse : function (timestamp) {
var target = +timestamp,
offsets = this.offsets,
untils = this.untils,
max = untils.length - 1,
offset, offsetNext, offsetPrev, i;
for (i = 0; i < max; i++) {
offset = offsets[i];
offsetNext = offsets[i + 1];
offsetPrev = offsets[i ? i - 1 : i];
if (offset < offsetNext && tz.moveAmbiguousForward) {
offset = offsetNext;
} else if (offset > offsetPrev && tz.moveInvalidForward) {
offset = offsetPrev;
}
if (target < untils[i] - (offset * 60000)) {
return offsets[i];
}
}
return offsets[max];
},
abbr : function (mom) {
return this.abbrs[this._index(mom)];
},
offset : function (mom) {
logError("zone.offset has been deprecated in favor of zone.utcOffset");
return this.offsets[this._index(mom)];
},
utcOffset : function (mom) {
return this.offsets[this._index(mom)];
}
};
/************************************
Country object
************************************/
function Country (country_name, zone_names) {
this.name = country_name;
this.zones = zone_names;
}
/************************************
Current Timezone
************************************/
function OffsetAt(at) {
var timeString = at.toTimeString();
var abbr = timeString.match(/\([a-z ]+\)/i);
if (abbr && abbr[0]) {
// 17:56:31 GMT-0600 (CST)
// 17:56:31 GMT-0600 (Central Standard Time)
abbr = abbr[0].match(/[A-Z]/g);
abbr = abbr ? abbr.join('') : undefined;
} else {
// 17:56:31 CST
// 17:56:31 GMT+0800 (台北標準時間)
abbr = timeString.match(/[A-Z]{3,5}/g);
abbr = abbr ? abbr[0] : undefined;
}
if (abbr === 'GMT') {
abbr = undefined;
}
this.at = +at;
this.abbr = abbr;
this.offset = at.getTimezoneOffset();
}
function ZoneScore(zone) {
this.zone = zone;
this.offsetScore = 0;
this.abbrScore = 0;
}
ZoneScore.prototype.scoreOffsetAt = function (offsetAt) {
this.offsetScore += Math.abs(this.zone.utcOffset(offsetAt.at) - offsetAt.offset);
if (this.zone.abbr(offsetAt.at).replace(/[^A-Z]/g, '') !== offsetAt.abbr) {
this.abbrScore++;
}
};
function findChange(low, high) {
var mid, diff;
while ((diff = ((high.at - low.at) / 12e4 | 0) * 6e4)) {
mid = new OffsetAt(new Date(low.at + diff));
if (mid.offset === low.offset) {
low = mid;
} else {
high = mid;
}
}
return low;
}
function userOffsets() {
var startYear = new Date().getFullYear() - 2,
last = new OffsetAt(new Date(startYear, 0, 1)),
offsets = [last],
change, next, i;
for (i = 1; i < 48; i++) {
next = new OffsetAt(new Date(startYear, i, 1));
if (next.offset !== last.offset) {
change = findChange(last, next);
offsets.push(change);
offsets.push(new OffsetAt(new Date(change.at + 6e4)));
}
last = next;
}
for (i = 0; i < 4; i++) {
offsets.push(new OffsetAt(new Date(startYear + i, 0, 1)));
offsets.push(new OffsetAt(new Date(startYear + i, 6, 1)));
}
return offsets;
}
function sortZoneScores (a, b) {
if (a.offsetScore !== b.offsetScore) {
return a.offsetScore - b.offsetScore;
}
if (a.abbrScore !== b.abbrScore) {
return a.abbrScore - b.abbrScore;
}
if (a.zone.population !== b.zone.population) {
return b.zone.population - a.zone.population;
}
return b.zone.name.localeCompare(a.zone.name);
}
function addToGuesses (name, offsets) {
var i, offset;
arrayToInt(offsets);
for (i = 0; i < offsets.length; i++) {
offset = offsets[i];
guesses[offset] = guesses[offset] || {};
guesses[offset][name] = true;
}
}
function guessesForUserOffsets (offsets) {
var offsetsLength = offsets.length,
filteredGuesses = {},
out = [],
i, j, guessesOffset;
for (i = 0; i < offsetsLength; i++) {
guessesOffset = guesses[offsets[i].offset] || {};
for (j in guessesOffset) {
if (guessesOffset.hasOwnProperty(j)) {
filteredGuesses[j] = true;
}
}
}
for (i in filteredGuesses) {
if (filteredGuesses.hasOwnProperty(i)) {
out.push(names[i]);
}
}
return out;
}
function rebuildGuess () {
// use Intl API when available and returning valid time zone
try {
var intlName = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (intlName && intlName.length > 3) {
var name = names[normalizeName(intlName)];
if (name) {
return name;
}
logError("Moment Timezone found " + intlName + " from the Intl api, but did not have that data loaded.");
}
} catch (e) {
// Intl unavailable, fall back to manual guessing.
}
var offsets = userOffsets(),
offsetsLength = offsets.length,
guesses = guessesForUserOffsets(offsets),
zoneScores = [],
zoneScore, i, j;
for (i = 0; i < guesses.length; i++) {
zoneScore = new ZoneScore(getZone(guesses[i]), offsetsLength);
for (j = 0; j < offsetsLength; j++) {
zoneScore.scoreOffsetAt(offsets[j]);
}
zoneScores.push(zoneScore);
}
zoneScores.sort(sortZoneScores);
return zoneScores.length > 0 ? zoneScores[0].zone.name : undefined;
}
function guess (ignoreCache) {
if (!cachedGuess || ignoreCache) {
cachedGuess = rebuildGuess();
}
return cachedGuess;
}
/************************************
Global Methods
************************************/
function normalizeName (name) {
return (name || '').toLowerCase().replace(/\//g, '_');
}
function addZone (packed) {
var i, name, split, normalized;
if (typeof packed === "string") {
packed = [packed];
}
for (i = 0; i < packed.length; i++) {
split = packed[i].split('|');
name = split[0];
normalized = normalizeName(name);
zones[normalized] = packed[i];
names[normalized] = name;
addToGuesses(normalized, split[2].split(' '));
}
}
function getZone (name, caller) {
name = normalizeName(name);
var zone = zones[name];
var link;
if (zone instanceof Zone) {
return zone;
}
if (typeof zone === 'string') {
zone = new Zone(zone);
zones[name] = zone;
return zone;
}
// Pass getZone to prevent recursion more than 1 level deep
if (links[name] && caller !== getZone && (link = getZone(links[name], getZone))) {
zone = zones[name] = new Zone();
zone._set(link);
zone.name = names[name];
return zone;
}
return null;
}
function getNames () {
var i, out = [];
for (i in names) {
if (names.hasOwnProperty(i) && (zones[i] || zones[links[i]]) && names[i]) {
out.push(names[i]);
}
}
return out.sort();
}
function getCountryNames () {
return Object.keys(countries);
}
function addLink (aliases) {
var i, alias, normal0, normal1;
if (typeof aliases === "string") {
aliases = [aliases];
}
for (i = 0; i < aliases.length; i++) {
alias = aliases[i].split('|');
normal0 = normalizeName(alias[0]);
normal1 = normalizeName(alias[1]);
links[normal0] = normal1;
names[normal0] = alias[0];
links[normal1] = normal0;
names[normal1] = alias[1];
}
}
function addCountries (data) {
var i, country_code, country_zones, split;
if (!data || !data.length) return;
for (i = 0; i < data.length; i++) {
split = data[i].split('|');
country_code = split[0].toUpperCase();
country_zones = split[1].split(' ');
countries[country_code] = new Country(
country_code,
country_zones
);
}
}
function getCountry (name) {
name = name.toUpperCase();
return countries[name] || null;
}
function zonesForCountry(country, with_offset) {
country = getCountry(country);
if (!country) return null;
var zones = country.zones.sort();
if (with_offset) {
return zones.map(function (zone_name) {
var zone = getZone(zone_name);
return {
name: zone_name,
offset: zone.utcOffset(new Date())
};
});
}
return zones;
}
function loadData (data) {
addZone(data.zones);
addLink(data.links);
addCountries(data.countries);
tz.dataVersion = data.version;
}
function zoneExists (name) {
if (!zoneExists.didShowError) {
zoneExists.didShowError = true;
logError("moment.tz.zoneExists('" + name + "') has been deprecated in favor of !moment.tz.zone('" + name + "')");
}
return !!getZone(name);
}
function needsOffset (m) {
var isUnixTimestamp = (m._f === 'X' || m._f === 'x');
return !!(m._a && (m._tzm === undefined) && !isUnixTimestamp);
}
function logError (message) {
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(message);
}
}
/************************************
moment.tz namespace
************************************/
function tz (input) {
var args = Array.prototype.slice.call(arguments, 0, -1),
name = arguments[arguments.length - 1],
zone = getZone(name),
out = moment.utc.apply(null, args);
if (zone && !moment.isMoment(input) && needsOffset(out)) {
out.add(zone.parse(out), 'minutes');
}
out.tz(name);
return out;
}
tz.version = VERSION;
tz.dataVersion = '';
tz._zones = zones;
tz._links = links;
tz._names = names;
tz._countries = countries;
tz.add = addZone;
tz.link = addLink;
tz.load = loadData;
tz.zone = getZone;
tz.zoneExists = zoneExists; // deprecated in 0.1.0
tz.guess = guess;
tz.names = getNames;
tz.Zone = Zone;
tz.unpack = unpack;
tz.unpackBase60 = unpackBase60;
tz.needsOffset = needsOffset;
tz.moveInvalidForward = true;
tz.moveAmbiguousForward = false;
tz.countries = getCountryNames;
tz.zonesForCountry = zonesForCountry;
/************************************
Interface with Moment.js
************************************/
var fn = moment.fn;
moment.tz = tz;
moment.defaultZone = null;
moment.updateOffset = function (mom, keepTime) {
var zone = moment.defaultZone,
offset;
if (mom._z === undefined) {
if (zone && needsOffset(mom) && !mom._isUTC) {
mom._d = moment.utc(mom._a)._d;
mom.utc().add(zone.parse(mom), 'minutes');
}
mom._z = zone;
}
if (mom._z) {
offset = mom._z.utcOffset(mom);
if (Math.abs(offset) < 16) {
offset = offset / 60;
}
if (mom.utcOffset !== undefined) {
var z = mom._z;
mom.utcOffset(-offset, keepTime);
mom._z = z;
} else {
mom.zone(offset, keepTime);
}
}
};
fn.tz = function (name, keepTime) {
if (name) {
if (typeof name !== 'string') {
throw new Error('Time zone name must be a string, got ' + name + ' [' + typeof name + ']');
}
this._z = getZone(name);
if (this._z) {
moment.updateOffset(this, keepTime);
} else {
logError("Moment Timezone has no data for " + name + ". See http://momentjs.com/timezone/docs/#/data-loading/.");
}
return this;
}
if (this._z) { return this._z.name; }
};
function abbrWrap (old) {
return function () {
if (this._z) { return this._z.abbr(this); }
return old.call(this);
};
}
function resetZoneWrap (old) {
return function () {
this._z = null;
return old.apply(this, arguments);
};
}
function resetZoneWrap2 (old) {
return function () {
if (arguments.length > 0) this._z = null;
return old.apply(this, arguments);
};
}
fn.zoneName = abbrWrap(fn.zoneName);
fn.zoneAbbr = abbrWrap(fn.zoneAbbr);
fn.utc = resetZoneWrap(fn.utc);
fn.local = resetZoneWrap(fn.local);
fn.utcOffset = resetZoneWrap2(fn.utcOffset);
moment.tz.setDefault = function(name) {
if (major < 2 || (major === 2 && minor < 9)) {
logError('Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js ' + moment.version + '.');
}
moment.defaultZone = name ? getZone(name) : null;
return moment;
};
// Cloning a moment should include the _z property.
var momentProperties = moment.momentProperties;
if (Object.prototype.toString.call(momentProperties) === '[object Array]') {
// moment 2.8.1+
momentProperties.push('_z');
momentProperties.push('_a');
} else if (momentProperties) {
// moment 2.7.0
momentProperties._z = null;
}
// INJECT DATA
return moment;
}));

@ -0,0 +1,55 @@
{
"name": "moment-timezone",
"version": "0.5.43",
"description": "Parse and display moments in any timezone.",
"homepage": "http://momentjs.com/timezone/",
"author": "Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)",
"keywords": [
"moment",
"date",
"time",
"timezone",
"olson",
"iana",
"zone",
"tz"
],
"main": "./index.js",
"typings": "./index.d.ts",
"engines": {
"node": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/moment/moment-timezone.git"
},
"bugs": {
"url": "https://github.com/moment/moment-timezone/issues"
},
"license": "MIT",
"dependencies": {
"moment": "^2.29.4"
},
"devDependencies": {
"grunt": "^1.5.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-nodeunit": "^4.0.0",
"grunt-contrib-uglify": "^5.2.2",
"grunt-exec": "^3.0.0",
"typescript": "^3.5.1"
},
"jspm": {
"main": "builds/moment-timezone-with-data",
"shim": {
"moment-timezone": {
"deps": [
"moment"
]
}
}
},
"scripts": {
"test": "grunt"
}
}

20
package-lock.json generated

@ -39,6 +39,7 @@
"gridfile": "^1.1.3", "gridfile": "^1.1.3",
"libphonenumber-js": "^1.9.6", "libphonenumber-js": "^1.9.6",
"moment": "^2.29.4", "moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"mongodb": "^5.0.1", "mongodb": "^5.0.1",
"mongoose": "^5.11.8", "mongoose": "^5.11.8",
"multer-gridfs-storage": "^5.0.2", "multer-gridfs-storage": "^5.0.2",
@ -6908,6 +6909,17 @@
"node": "*" "node": "*"
} }
}, },
"node_modules/moment-timezone": {
"version": "0.5.43",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz",
"integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==",
"dependencies": {
"moment": "^2.29.4"
},
"engines": {
"node": "*"
}
},
"node_modules/mongodb": { "node_modules/mongodb": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz",
@ -15450,6 +15462,14 @@
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
}, },
"moment-timezone": {
"version": "0.5.43",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz",
"integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==",
"requires": {
"moment": "^2.29.4"
}
},
"mongodb": { "mongodb": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz",

@ -40,6 +40,7 @@
"gridfile": "^1.1.3", "gridfile": "^1.1.3",
"libphonenumber-js": "^1.9.6", "libphonenumber-js": "^1.9.6",
"moment": "^2.29.4", "moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"mongodb": "^5.0.1", "mongodb": "^5.0.1",
"mongoose": "^5.11.8", "mongoose": "^5.11.8",
"multer-gridfs-storage": "^5.0.2", "multer-gridfs-storage": "^5.0.2",

@ -4,8 +4,12 @@ const boom = require("boom");
const fastify = require("fastify")({ const fastify = require("fastify")({
logger: true, logger: true,
}); });
const moment = require('moment'); // const moment = require('moment');
const moment = require('moment-timezone');
// Set the timezone of the server
moment.tz.setDefault('Asia/Kolkata');
const schedule = require('node-schedule'); const schedule = require('node-schedule');
@ -106,6 +110,54 @@ const schedule = require('node-schedule');
// }; // };
// exports.friendRequest = async (request, reply) => {
// try {
// const customerId = request.body.customerId;
// const supplierId = request.body.supplierId;
// const sender = await User.findOne({ customerId: customerId });
// const receiver = await Supplier.findOne({ supplierId: supplierId });
// if (!sender || !receiver) {
// throw new Error('Sender or receiver not found');
// }
// const existingRequest = await FriendRequest.findOne({ customerId: sender.customerId, supplierId: receiver.supplierId});
// if (existingRequest) {
// existingRequest.timestamp = moment().format("DD-MM-YYYY hh:mm:ss")
// await existingRequest.save();
// reply.send({ timestamp: existingRequest.timestamp, message: 'Friend request sent again' });
// } else {
// const timestamp = moment().format("DD-MM-YYYY hh:mm:ss")
// const friendRequest = new FriendRequest({
// customerId: sender.customerId,
// supplierId: receiver.supplierId,
// timestamp: timestamp
// });
// await friendRequest.save();
// // Schedule the request to be sent again in 5 hours
// const rule = new schedule.RecurrenceRule();
// rule.hour = new schedule.Range(0, 23, 5); // Run every 5 hours
// schedule.scheduleJob(rule, async function() {
// const newTimestamp = moment().format("DD-MM-YYYY hh:mm:ss")
// const newFriendRequest = new FriendRequest({
// customerId: sender.customerId,
// supplierId: receiver.supplierId,
// timestamp: newTimestamp
// });
// await newFriendRequest.save();
// });
// reply.send({ timestamp: friendRequest.timestamp, message: 'Friend request sent' });
// }
// } catch (err) {
// reply.status(400).send({ error: err.message });
// }
// };
exports.friendRequest = async (request, reply) => { exports.friendRequest = async (request, reply) => {
try { try {
const customerId = request.body.customerId; const customerId = request.body.customerId;
@ -121,11 +173,12 @@ exports.friendRequest = async (request, reply) => {
const existingRequest = await FriendRequest.findOne({ customerId: sender.customerId, supplierId: receiver.supplierId}); const existingRequest = await FriendRequest.findOne({ customerId: sender.customerId, supplierId: receiver.supplierId});
if (existingRequest) { if (existingRequest) {
existingRequest.timestamp = moment().format("DD-MM-YYYY hh:mm:ss") existingRequest.timestamp = moment().tz('Asia/Kolkata').format("DD-MM-YYYY hh:mm:ss");
await existingRequest.save(); await existingRequest.save();
reply.send({ timestamp: existingRequest.timestamp, message: 'Friend request sent again' }); reply.send({ timestamp: existingRequest.timestamp, message: 'Friend request sent again' });
} else { } else {
const timestamp = moment().format("DD-MM-YYYY hh:mm:ss") const timestamp = moment().tz('Asia/Kolkata').format("DD-MM-YYYY hh:mm:ss");
const friendRequest = new FriendRequest({ const friendRequest = new FriendRequest({
customerId: sender.customerId, customerId: sender.customerId,
@ -139,11 +192,11 @@ exports.friendRequest = async (request, reply) => {
const rule = new schedule.RecurrenceRule(); const rule = new schedule.RecurrenceRule();
rule.hour = new schedule.Range(0, 23, 5); // Run every 5 hours rule.hour = new schedule.Range(0, 23, 5); // Run every 5 hours
schedule.scheduleJob(rule, async function() { schedule.scheduleJob(rule, async function() {
const newTimestamp = moment().format("DD-MM-YYYY hh:mm:ss") const timestamp = moment().tz('Asia/Kolkata').format("DD-MM-YYYY hh:mm:ss");
const newFriendRequest = new FriendRequest({ const newFriendRequest = new FriendRequest({
customerId: sender.customerId, customerId: sender.customerId,
supplierId: receiver.supplierId, supplierId: receiver.supplierId,
timestamp: newTimestamp timestamp: timestamp
}); });
await newFriendRequest.save(); await newFriendRequest.save();
}); });

Loading…
Cancel
Save