date-fns-tz
Advanced tools
Comparing version 1.0.12 to 1.1.0
@@ -66,7 +66,8 @@ "use strict"; | ||
if (token) { | ||
// var [fYear, fMonth, fDay, fHour, fMinute, fSecond] = tzTokenizeDate(date, timezoneString) | ||
date = new Date(date || Date.now()); | ||
date.setMilliseconds(0); // var [fYear, fMonth, fDay, fHour, fMinute, fSecond] = tzTokenizeDate(date, timezoneString) | ||
var tokens = (0, _index.default)(date, timezoneString); | ||
var asUTC = Date.UTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3], tokens[4], tokens[5]); | ||
var timestampWithMsZeroed = date.getTime() - date.getTime() % 1000; | ||
return -(asUTC - timestampWithMsZeroed); | ||
return -(asUTC - date.getTime()); | ||
} | ||
@@ -73,0 +74,0 @@ |
@@ -22,3 +22,3 @@ const path = require('path') | ||
'ISO Week-Numbering Year Helpers', | ||
'Decade Helpers' | ||
'Decade Helpers', | ||
], | ||
@@ -30,5 +30,5 @@ | ||
{ | ||
fullPath: path.join(__dirname, 'OptionsWithTZ.js') | ||
} | ||
] | ||
fullPath: path.join(__dirname, 'OptionsWithTZ.js'), | ||
}, | ||
], | ||
} |
@@ -32,4 +32,4 @@ /** | ||
timeZone: timeZone, | ||
timeZoneName: length | ||
timeZoneName: length, | ||
}) | ||
} |
@@ -11,3 +11,3 @@ import tzTokenizeDate from '../tzTokenizeDate/index.js' | ||
timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/, | ||
timezoneIANA: /(UTC|(?:[a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?))$/ | ||
timezoneIANA: /(UTC|(?:[a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?))$/, | ||
} | ||
@@ -51,4 +51,3 @@ | ||
absoluteOffset = | ||
hours * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE | ||
absoluteOffset = hours * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE | ||
return token[1] === '+' ? -absoluteOffset : absoluteOffset | ||
@@ -60,14 +59,8 @@ } | ||
if (token) { | ||
date = new Date(date || Date.now()) | ||
date.setMilliseconds(0) | ||
// var [fYear, fMonth, fDay, fHour, fMinute, fSecond] = tzTokenizeDate(date, timezoneString) | ||
var tokens = tzTokenizeDate(date, timezoneString) | ||
var asUTC = Date.UTC( | ||
tokens[0], | ||
tokens[1] - 1, | ||
tokens[2], | ||
tokens[3], | ||
tokens[4], | ||
tokens[5] | ||
) | ||
var timestampWithMsZeroed = date.getTime() - (date.getTime() % 1000) | ||
return -(asUTC - timestampWithMsZeroed) | ||
var asUTC = Date.UTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3], tokens[4], tokens[5]) | ||
return -(asUTC - date.getTime()) | ||
} | ||
@@ -74,0 +67,0 @@ |
@@ -16,3 +16,3 @@ /** | ||
minute: 4, | ||
second: 5 | ||
second: 5, | ||
} | ||
@@ -56,3 +56,3 @@ | ||
minute: '2-digit', | ||
second: '2-digit' | ||
second: '2-digit', | ||
}).format(new Date('2014-06-25T04:00:00.123Z')) | ||
@@ -72,3 +72,3 @@ var hourCycleSupported = | ||
minute: '2-digit', | ||
second: '2-digit' | ||
second: '2-digit', | ||
}) | ||
@@ -83,3 +83,3 @@ : new Intl.DateTimeFormat('en-US', { | ||
minute: '2-digit', | ||
second: '2-digit' | ||
second: '2-digit', | ||
}) | ||
@@ -86,0 +86,0 @@ } |
@@ -8,3 +8,3 @@ import tzIntlTimeZoneName from '../../_lib/tzIntlTimeZoneName' | ||
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`) | ||
X: function(date, token, localize, options) { | ||
X: function (date, token, localize, options) { | ||
var originalDate = options._originalDate || date | ||
@@ -42,3 +42,3 @@ var timezoneOffset = options.timeZone | ||
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) | ||
x: function(date, token, localize, options) { | ||
x: function (date, token, localize, options) { | ||
var originalDate = options._originalDate || date | ||
@@ -72,3 +72,3 @@ var timezoneOffset = options.timeZone | ||
// Timezone (GMT) | ||
O: function(date, token, localize, options) { | ||
O: function (date, token, localize, options) { | ||
var originalDate = options._originalDate || date | ||
@@ -93,3 +93,3 @@ var timezoneOffset = options.timeZone | ||
// Timezone (specific non-location) | ||
z: function(date, token, localize, options) { | ||
z: function (date, token, localize, options) { | ||
var originalDate = options._originalDate || date | ||
@@ -108,3 +108,3 @@ | ||
} | ||
} | ||
}, | ||
} | ||
@@ -111,0 +111,0 @@ |
@@ -324,9 +324,6 @@ import dateFnsFormat from 'date-fns/esm/format' | ||
var date = toDate(dirtyDate, options) | ||
formatStr = matches.reduce(function(result, token) { | ||
formatStr = matches.reduce(function (result, token) { | ||
return token[0] === "'" | ||
? result | ||
: result.replace( | ||
token, | ||
"'" + formatters[token[0]](date, token, null, options) + "'" | ||
) | ||
: result.replace(token, "'" + formatters[token[0]](date, token, null, options) + "'") | ||
}, formatStr) | ||
@@ -333,0 +330,0 @@ } |
@@ -5,11 +5,8 @@ // This file is generated automatically by `scripts/build/indices.js`. Please, don't change it. | ||
export { default as formatWithOptions } from './formatWithOptions/index.js' | ||
export { default as getTimezoneOffset } from './getTimezoneOffset/index.js' | ||
export { default as toDate } from './toDate/index.js' | ||
export { default as toDateWithOptions } from './toDateWithOptions/index.js' | ||
export { default as utcToZonedTime } from './utcToZonedTime/index.js' | ||
export { | ||
default as utcToZonedTimeWithOptions | ||
} from './utcToZonedTimeWithOptions/index.js' | ||
export { default as utcToZonedTimeWithOptions } from './utcToZonedTimeWithOptions/index.js' | ||
export { default as zonedTimeToUtc } from './zonedTimeToUtc/index.js' | ||
export { | ||
default as zonedTimeToUtcWithOptions | ||
} from './zonedTimeToUtcWithOptions/index.js' | ||
export { default as zonedTimeToUtcWithOptions } from './zonedTimeToUtcWithOptions/index.js' |
// This file is generated automatically by `scripts/build/indices.js`. Please, don't change it. | ||
export { default as format } from './format/index.js' | ||
export { default as getTimezoneOffset } from './getTimezoneOffset/index.js' | ||
export { default as toDate } from './toDate/index.js' | ||
export { default as utcToZonedTime } from './utcToZonedTime/index.js' | ||
export { default as zonedTimeToUtc } from './zonedTimeToUtc/index.js' |
@@ -19,3 +19,3 @@ import toInteger from 'date-fns/esm/_lib/toInteger/index.js' | ||
/^([+-]\d{3})$/, // 1 additional digit | ||
/^([+-]\d{4})$/ // 2 additional digits | ||
/^([+-]\d{4})$/, // 2 additional digits | ||
], | ||
@@ -26,3 +26,3 @@ YYYY: /^(\d{4})/, | ||
/^([+-]\d{5})/, // 1 additional digit | ||
/^([+-]\d{6})/ // 2 additional digits | ||
/^([+-]\d{6})/, // 2 additional digits | ||
], | ||
@@ -42,3 +42,3 @@ | ||
// timezone tokens (to identify the presence of a tz) | ||
timezone: /([Z+-].*| UTC|(?:[a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?))$/ | ||
timezone: /([Z+-].*| UTC|(?:[a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?))$/, | ||
} | ||
@@ -89,5 +89,3 @@ | ||
if (arguments.length < 1) { | ||
throw new TypeError( | ||
'1 argument required, but only ' + arguments.length + ' present' | ||
) | ||
throw new TypeError('1 argument required, but only ' + arguments.length + ' present') | ||
} | ||
@@ -105,7 +103,3 @@ | ||
: toInteger(options.additionalDigits) | ||
if ( | ||
additionalDigits !== 2 && | ||
additionalDigits !== 1 && | ||
additionalDigits !== 0 | ||
) { | ||
if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) { | ||
throw new RangeError('additionalDigits must be 0, 1 or 2') | ||
@@ -117,4 +111,3 @@ } | ||
argument instanceof Date || | ||
(typeof argument === 'object' && | ||
Object.prototype.toString.call(argument) === '[object Date]') | ||
(typeof argument === 'object' && Object.prototype.toString.call(argument) === '[object Date]') | ||
) { | ||
@@ -130,4 +123,3 @@ // Prevent the date to lose the milliseconds when passed to new Date() in IE10 | ||
!( | ||
typeof argument === 'string' || | ||
Object.prototype.toString.call(argument) === '[object String]' | ||
typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]' | ||
) | ||
@@ -164,6 +156,3 @@ ) { | ||
if (dateStrings.timezone || options.timeZone) { | ||
offset = tzParseTimezone( | ||
dateStrings.timezone || options.timeZone, | ||
new Date(timestamp + time) | ||
) | ||
offset = tzParseTimezone(dateStrings.timezone || options.timeZone, new Date(timestamp + time)) | ||
if (isNaN(offset)) { | ||
@@ -182,5 +171,3 @@ return new Date(NaN) | ||
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time)) | ||
offset = getTimezoneOffsetInMilliseconds( | ||
new Date(timestamp + time + offset) | ||
) | ||
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time + offset)) | ||
} | ||
@@ -237,3 +224,3 @@ | ||
year: parseInt(yearString, 10), | ||
restDateString: dateString.slice(yearString.length) | ||
restDateString: dateString.slice(yearString.length), | ||
} | ||
@@ -248,3 +235,3 @@ } | ||
year: parseInt(centuryString, 10) * 100, | ||
restDateString: dateString.slice(centuryString.length) | ||
restDateString: dateString.slice(centuryString.length), | ||
} | ||
@@ -255,3 +242,3 @@ } | ||
return { | ||
year: null | ||
year: null, | ||
} | ||
@@ -377,5 +364,3 @@ } | ||
return ( | ||
(hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE | ||
) | ||
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE | ||
} | ||
@@ -394,7 +379,3 @@ | ||
return ( | ||
(hours % 24) * MILLISECONDS_IN_HOUR + | ||
minutes * MILLISECONDS_IN_MINUTE + | ||
seconds * 1000 | ||
) | ||
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE + seconds * 1000 | ||
} | ||
@@ -401,0 +382,0 @@ |
@@ -45,5 +45,3 @@ import tzParseTimezone from '../_lib/tzParseTimezone' | ||
return offsetMilliseconds | ||
? subMilliseconds(utcDate, offsetMilliseconds) | ||
: utcDate | ||
return offsetMilliseconds ? subMilliseconds(utcDate, offsetMilliseconds) : utcDate | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
formatWithOptions: require('./formatWithOptions/index.js'), | ||
getTimezoneOffset: require('./getTimezoneOffset/index.js'), | ||
toDate: require('./toDate/index.js'), | ||
@@ -9,0 +10,0 @@ toDateWithOptions: require('./toDateWithOptions/index.js'), |
@@ -6,2 +6,3 @@ "use strict"; | ||
format: require('./format/index.js'), | ||
getTimezoneOffset: require('./getTimezoneOffset/index.js'), | ||
toDate: require('./toDate/index.js'), | ||
@@ -8,0 +9,0 @@ utcToZonedTime: require('./utcToZonedTime/index.js'), |
@@ -5,18 +5,18 @@ The MIT License (MIT) | ||
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 | ||
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 | ||
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 | ||
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. |
{ | ||
"name": "date-fns-tz", | ||
"version": "1.0.12", | ||
"version": "1.1.0", | ||
"sideEffects": false, | ||
@@ -20,2 +20,4 @@ "description": "Time zone support for date-fns v2 with the browser Intl API", | ||
"test": "karma start config/karma.js", | ||
"test:watch": "cross-env TEST_WATCH=true karma start config/karma.js", | ||
"prettier": "prettier . --write", | ||
"lint": "eslint .", | ||
@@ -31,4 +33,6 @@ "lint-types": "eslint --config=.ts-eslintrc.js typings.d.ts" | ||
"*.js": [ | ||
"prettier --write", | ||
"git add" | ||
"eslint" | ||
], | ||
"*.{js,json,md,ts}": [ | ||
"prettier --write" | ||
] | ||
@@ -49,14 +53,15 @@ }, | ||
"@babel/plugin-transform-template-literals": "^7.4.4", | ||
"@typescript-eslint/eslint-plugin": "^2.3.3", | ||
"@typescript-eslint/parser": "^2.3.3", | ||
"@typescript-eslint/eslint-plugin": "^4.4.0", | ||
"@typescript-eslint/parser": "^4.4.0", | ||
"babel-eslint": "^10.0.2", | ||
"babel-loader": "8.0.6", | ||
"babel-loader": "^8.0.6", | ||
"babel-plugin-add-module-exports": "^1.0.2", | ||
"babel-preset-power-assert": "^3.0.0", | ||
"date-fns": "latest", | ||
"eslint": "^6.5.1", | ||
"eslint-config-prettier": "^6.4.0", | ||
"flow-bin": "^0.109.0", | ||
"cross-env": "^7.0.3", | ||
"date-fns": "^2.16.1", | ||
"eslint": "^7.11.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"flow-bin": "^0.143.1", | ||
"fs-promise": "^2.0.3", | ||
"husky": "^3.0.8", | ||
"husky": "^4.3.0", | ||
"jsdoc-to-markdown": "leshakoss/jsdoc-to-markdown", | ||
@@ -74,3 +79,3 @@ "json-loader": "^0.5.3", | ||
"karma-webpack": "^4.0.2", | ||
"lint-staged": "^9.4.2", | ||
"lint-staged": "^10.4.0", | ||
"lodash": "^4.17.15", | ||
@@ -80,3 +85,4 @@ "lodash.clonedeep": "^4.5.0", | ||
"power-assert": "^1.6.1", | ||
"prettier": "^1.18.2", | ||
"prettier": "^2.2.1", | ||
"typescript": "^4.1.3", | ||
"webpack": "^4.41.1", | ||
@@ -83,0 +89,0 @@ "webpack-cli": "^3.1.2" |
@@ -16,7 +16,7 @@ # date-fns-tz | ||
- [Time Zone Helpers](#time-zone-helpers) | ||
- [`zonedTimeToUtc`](#zonedtimetoutc) - Given a date and any time zone, returns a `Date` with the equivalent UTC time | ||
- [`utcToZonedTime`](#utctozonedtime) - Get a date/time representing local time in a given time zone from the UTC date | ||
- [`zonedTimeToUtc`](#zonedtimetoutc) - Given a date and any time zone, returns a `Date` with the equivalent UTC time | ||
- [`utcToZonedTime`](#utctozonedtime) - Get a date/time representing local time in a given time zone from the UTC date | ||
- [Time Zone Formatting](#time-zone-formatting) | ||
- [`format`](#format) - Extends `date-fns/format` with full time zone support | ||
- [`toDate`](#todate) - Can be used to create a zoned Date from a string containing an offset or IANA time zone | ||
- [`format`](#format) - Extends `date-fns/format` with full time zone support | ||
- [`toDate`](#todate) - Can be used to create a zoned Date from a string containing an offset or IANA time zone | ||
- [Usage with Node.js](#usage-with-nodejs) | ||
@@ -32,5 +32,6 @@ | ||
In this case there are two relevant pieces of information: | ||
- a fixed moment in time in the form of a timestamp, UTC or ISO date string, and | ||
- the time zone descriptor, usually an offset or IANA time zone name (e.g. `America/New_York`). | ||
- a fixed moment in time in the form of a timestamp, UTC or ISO date string, and | ||
- the time zone descriptor, usually an offset or IANA time zone name (e.g. `America/New_York`). | ||
Libraries like Moment and Luxon, which provide their own date time classes, manage these timestamp and time | ||
@@ -63,6 +64,6 @@ zone values internally. Since `date-fns` always returns a plain JS Date, which implicitly has the current | ||
const date = getDatePickerValue() // e.g. 2014-06-25 10:00:00 (picked in any time zone) | ||
const timeZone = getTimeZoneValue() // e.g. America/Los_Angeles | ||
const date = getDatePickerValue() // e.g. 2014-06-25 10:00:00 (picked in any time zone) | ||
const timeZone = getTimeZoneValue() // e.g. America/Los_Angeles | ||
const utcDate = zonedTimeToUtc(date, timeZone) // In June 10am in Los Angeles is 5pm UTC | ||
const utcDate = zonedTimeToUtc(date, timeZone) // In June 10am in Los Angeles is 5pm UTC | ||
@@ -87,10 +88,38 @@ postToServer(utcDate.toISOString(), timeZone) // post 2014-06-25T17:00:00.000Z, America/Los_Angeles | ||
const { isoDate, timeZone } = fetchInitialValues() // 2014-06-25T10:00:00.000Z, America/New_York | ||
const { isoDate, timeZone } = fetchInitialValues() // 2014-06-25T10:00:00.000Z, America/New_York | ||
const date = utcToZonedTime(isoDate, timeZone) // In June 10am UTC is 6am in New York (-04:00) | ||
const date = utcToZonedTime(isoDate, timeZone) // In June 10am UTC is 6am in New York (-04:00) | ||
renderDatePicker(date) // 2014-06-25 06:00:00 (in the system time zone) | ||
renderTimeZoneSelect(timeZone) // America/New_York | ||
renderDatePicker(date) // 2014-06-25 06:00:00 (in the system time zone) | ||
renderTimeZoneSelect(timeZone) // America/New_York | ||
``` | ||
### `getTimezoneOffset` | ||
**Gets the offset in milliseconds between the time zone and UTC time** | ||
```js | ||
getTimezoneOffset(timeZone: String, date: Date|Number): Date | ||
``` | ||
Returns the time zone offset from UTC time in milliseconds for IANA time zones as well | ||
as other time zone offset string formats. | ||
For time zones where daylight savings time is applicable a `Date` should be passed on | ||
the second parameter to ensure the offset correctly accounts for DST at that time of | ||
year. When omitted, the current date is used. | ||
```javascript | ||
import { getTimezoneOffset } from 'date-fns-tz' | ||
const result = getTimezoneOffset('-07:00') | ||
//=> -18000000 (-7 * 60 * 60 * 1000) | ||
const result = getTimezoneOffset('Africa/Johannesburg') | ||
//=> 7200000 (2 * 60 * 60 * 1000) | ||
const result = getTimezoneOffset('America/New_York', new Date(2016, 0, 1)) | ||
//=> -18000000 (-5 * 60 * 60 * 1000) | ||
const result = getTimezoneOffset('America/New_York', new Date(2016, 6, 1)) | ||
//=> -14400000 (-4 * 60 * 60 * 1000) | ||
``` | ||
## Time Zone Formatting | ||
@@ -102,4 +131,4 @@ | ||
- The `z..zzz` Unicode tokens: *short specific non-location format* | ||
- The `zzzz` Unicode token: *long specific non-location format* | ||
- The `z..zzz` Unicode tokens: _short specific non-location format_ | ||
- The `zzzz` Unicode token: _long specific non-location format_ | ||
@@ -111,5 +140,5 @@ When using those tokens with `date-fns/format` it falls back to GMT timezones, and always uses the local | ||
To format a date to a string showing time for a specific time zone, which can be different from the system | ||
time zone, the `format` function can be combined with `utcToZonedTime` as shown in the example below. *To | ||
time zone, the `format` function can be combined with `utcToZonedTime` as shown in the example below. _To | ||
clarify, the `format` function will never change the underlying date, it must be changed to a zoned time | ||
before passing it to `format`.* | ||
before passing it to `format`._ | ||
@@ -131,5 +160,5 @@ Since a zoned time `Date` instance cannot convey the time zone information to the `format` function it is | ||
format(nyDate, 'yyyy-MM-dd HH:mm:ssXXX', { timeZone: 'America/New_York' }) // 2014-10-25 06:46:20-04:00 | ||
format(nyDate, 'yyyy-MM-dd HH:mm:ssXXX', { timeZone: 'America/New_York' }) // 2014-10-25 06:46:20-04:00 | ||
format(nyDate, 'yyyy-MM-dd HH:mm:ss zzz', { timeZone: 'America/New_York' }) // 2014-10-25 06:46:20 EST | ||
format(parisDate, 'yyyy-MM-dd HH:mm:ss zzz', { timeZone: 'Europe/Paris' }) // 2014-10-25 10:46:20 GMT+2 | ||
format(parisDate, 'yyyy-MM-dd HH:mm:ss zzz', { timeZone: 'Europe/Paris' }) // 2014-10-25 10:46:20 GMT+2 | ||
@@ -139,5 +168,11 @@ // The time zone name is generated by the Intl API which works best when a locale is also provided | ||
format(parisDate, 'yyyy-MM-dd HH:mm:ss zzz', { timeZone: 'Europe/Paris', locale: enGB }) | ||
format(parisDate, 'yyyy-MM-dd HH:mm:ss zzz', { | ||
timeZone: 'Europe/Paris', | ||
locale: enGB, | ||
}) | ||
// 2014-10-25 10:46:20 CEST | ||
format(parisDate, 'yyyy-MM-dd HH:mm:ss zzzz', { timeZone: 'Europe/Paris', locale: enGB }) | ||
format(parisDate, 'yyyy-MM-dd HH:mm:ss zzzz', { | ||
timeZone: 'Europe/Paris', | ||
locale: enGB, | ||
}) | ||
// 2014-10-25 10:46:20 Central European Summer Time | ||
@@ -144,0 +179,0 @@ ``` |
148
typings.d.ts
@@ -49,13 +49,9 @@ // This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. | ||
function format( | ||
date: Date | string | number, | ||
format: string, | ||
options?: OptionsWithTZ | ||
): string | ||
function format(date: Date | string | number, format: string, options?: OptionsWithTZ): string | ||
namespace format {} | ||
function toDate( | ||
argument: Date | string | number, | ||
options?: OptionsWithTZ | ||
): Date | ||
function getTimezoneOffset(timeZone: string, date?: Date | number): number | ||
namespace getTimezoneOffset {} | ||
function toDate(argument: Date | string | number, options?: OptionsWithTZ): Date | ||
namespace toDate {} | ||
@@ -83,2 +79,7 @@ | ||
declare module 'date-fns-tz/getTimezoneOffset' { | ||
import { getTimezoneOffset } from 'date-fns-tz' | ||
export = getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/toDate' { | ||
@@ -104,2 +105,7 @@ import { toDate } from 'date-fns-tz' | ||
declare module 'date-fns-tz/getTimezoneOffset/index' { | ||
import { getTimezoneOffset } from 'date-fns-tz' | ||
export = getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/toDate/index' { | ||
@@ -125,2 +131,7 @@ import { toDate } from 'date-fns-tz' | ||
declare module 'date-fns-tz/getTimezoneOffset/index.js' { | ||
import { getTimezoneOffset } from 'date-fns-tz' | ||
export = getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/toDate/index.js' { | ||
@@ -149,18 +160,12 @@ import { toDate } from 'date-fns-tz' | ||
const formatWithOptions: CurriedFn3< | ||
OptionsWithTZ, | ||
string, | ||
Date | string | number, | ||
string | ||
> | ||
const formatWithOptions: CurriedFn3<OptionsWithTZ, string, Date | string | number, string> | ||
namespace formatWithOptions {} | ||
const getTimezoneOffset: CurriedFn2<Date | number, string, number> | ||
namespace getTimezoneOffset {} | ||
const toDate: CurriedFn1<Date | string | number, Date> | ||
namespace toDate {} | ||
const toDateWithOptions: CurriedFn2< | ||
OptionsWithTZ, | ||
Date | string | number, | ||
Date | ||
> | ||
const toDateWithOptions: CurriedFn2<OptionsWithTZ, Date | string | number, Date> | ||
namespace toDateWithOptions {} | ||
@@ -171,8 +176,3 @@ | ||
const utcToZonedTimeWithOptions: CurriedFn3< | ||
OptionsWithTZ, | ||
string, | ||
Date | string | number, | ||
Date | ||
> | ||
const utcToZonedTimeWithOptions: CurriedFn3<OptionsWithTZ, string, Date | string | number, Date> | ||
namespace utcToZonedTimeWithOptions {} | ||
@@ -183,8 +183,3 @@ | ||
const zonedTimeToUtcWithOptions: CurriedFn3< | ||
OptionsWithTZ, | ||
string, | ||
Date | string | number, | ||
Date | ||
> | ||
const zonedTimeToUtcWithOptions: CurriedFn3<OptionsWithTZ, string, Date | string | number, Date> | ||
namespace zonedTimeToUtcWithOptions {} | ||
@@ -203,2 +198,7 @@ } | ||
declare module 'date-fns-tz/fp/getTimezoneOffset' { | ||
import { getTimezoneOffset } from 'date-fns-tz/fp' | ||
export = getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/fp/toDate' { | ||
@@ -244,2 +244,7 @@ import { toDate } from 'date-fns-tz/fp' | ||
declare module 'date-fns-tz/fp/getTimezoneOffset/index' { | ||
import { getTimezoneOffset } from 'date-fns-tz/fp' | ||
export = getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/fp/toDate/index' { | ||
@@ -285,2 +290,7 @@ import { toDate } from 'date-fns-tz/fp' | ||
declare module 'date-fns-tz/fp/getTimezoneOffset/index.js' { | ||
import { getTimezoneOffset } from 'date-fns-tz/fp' | ||
export = getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/fp/toDate/index.js' { | ||
@@ -321,13 +331,9 @@ import { toDate } from 'date-fns-tz/fp' | ||
function format( | ||
date: Date | string | number, | ||
format: string, | ||
options?: OptionsWithTZ | ||
): string | ||
function format(date: Date | string | number, format: string, options?: OptionsWithTZ): string | ||
namespace format {} | ||
function toDate( | ||
argument: Date | string | number, | ||
options?: OptionsWithTZ | ||
): Date | ||
function getTimezoneOffset(timeZone: string, date?: Date | number): number | ||
namespace getTimezoneOffset {} | ||
function toDate(argument: Date | string | number, options?: OptionsWithTZ): Date | ||
namespace toDate {} | ||
@@ -355,2 +361,7 @@ | ||
declare module 'date-fns-tz/esm/getTimezoneOffset' { | ||
import { getTimezoneOffset } from 'date-fns-tz/esm' | ||
export default getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/esm/toDate' { | ||
@@ -376,2 +387,7 @@ import { toDate } from 'date-fns-tz/esm' | ||
declare module 'date-fns-tz/esm/getTimezoneOffset/index' { | ||
import { getTimezoneOffset } from 'date-fns-tz/esm' | ||
export default getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/esm/toDate/index' { | ||
@@ -397,2 +413,7 @@ import { toDate } from 'date-fns-tz/esm' | ||
declare module 'date-fns-tz/esm/getTimezoneOffset/index.js' { | ||
import { getTimezoneOffset } from 'date-fns-tz/esm' | ||
export default getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/esm/toDate/index.js' { | ||
@@ -421,18 +442,12 @@ import { toDate } from 'date-fns-tz/esm' | ||
const formatWithOptions: CurriedFn3< | ||
OptionsWithTZ, | ||
string, | ||
Date | string | number, | ||
string | ||
> | ||
const formatWithOptions: CurriedFn3<OptionsWithTZ, string, Date | string | number, string> | ||
namespace formatWithOptions {} | ||
const getTimezoneOffset: CurriedFn2<Date | number, string, number> | ||
namespace getTimezoneOffset {} | ||
const toDate: CurriedFn1<Date | string | number, Date> | ||
namespace toDate {} | ||
const toDateWithOptions: CurriedFn2< | ||
OptionsWithTZ, | ||
Date | string | number, | ||
Date | ||
> | ||
const toDateWithOptions: CurriedFn2<OptionsWithTZ, Date | string | number, Date> | ||
namespace toDateWithOptions {} | ||
@@ -443,8 +458,3 @@ | ||
const utcToZonedTimeWithOptions: CurriedFn3< | ||
OptionsWithTZ, | ||
string, | ||
Date | string | number, | ||
Date | ||
> | ||
const utcToZonedTimeWithOptions: CurriedFn3<OptionsWithTZ, string, Date | string | number, Date> | ||
namespace utcToZonedTimeWithOptions {} | ||
@@ -455,8 +465,3 @@ | ||
const zonedTimeToUtcWithOptions: CurriedFn3< | ||
OptionsWithTZ, | ||
string, | ||
Date | string | number, | ||
Date | ||
> | ||
const zonedTimeToUtcWithOptions: CurriedFn3<OptionsWithTZ, string, Date | string | number, Date> | ||
namespace zonedTimeToUtcWithOptions {} | ||
@@ -475,2 +480,7 @@ } | ||
declare module 'date-fns-tz/esm/fp/getTimezoneOffset' { | ||
import { getTimezoneOffset } from 'date-fns-tz/esm/fp' | ||
export default getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/esm/fp/toDate' { | ||
@@ -516,2 +526,7 @@ import { toDate } from 'date-fns-tz/esm/fp' | ||
declare module 'date-fns-tz/esm/fp/getTimezoneOffset/index' { | ||
import { getTimezoneOffset } from 'date-fns-tz/esm/fp' | ||
export default getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/esm/fp/toDate/index' { | ||
@@ -557,2 +572,7 @@ import { toDate } from 'date-fns-tz/esm/fp' | ||
declare module 'date-fns-tz/esm/fp/getTimezoneOffset/index.js' { | ||
import { getTimezoneOffset } from 'date-fns-tz/esm/fp' | ||
export default getTimezoneOffset | ||
} | ||
declare module 'date-fns-tz/esm/fp/toDate/index.js' { | ||
@@ -559,0 +579,0 @@ import { toDate } from 'date-fns-tz/esm/fp' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
179653
136
3048
220
43