diff --git a/src/formatInTimeZone/index.js b/src/formatInTimeZone/index.js index 0676d84..36ffdfc 100644 --- a/src/formatInTimeZone/index.js +++ b/src/formatInTimeZone/index.js @@ -7,8 +7,9 @@ import utcToZonedTime from '../utcToZonedTime' * @category Time Zone Helpers * @summary Gets the offset in milliseconds between the time zone and Universal Coordinated Time (UTC) * - * @param {Date|Number} date - the date representing the local time / real UTC time + * @param {Date|String|Number} date - the date representing the local time / real UTC time * @param {String} timeZone - the time zone this date should be formatted for; can be an offset or IANA time zone + * @param {String} formatStr - the string of tokens * @param {OptionsWithTZ} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link * https://date-fns.org/docs/toDate} diff --git a/src/formatInTimeZone/index.js.flow b/src/formatInTimeZone/index.js.flow index 96104c0..55c4e6e 100644 --- a/src/formatInTimeZone/index.js.flow +++ b/src/formatInTimeZone/index.js.flow @@ -16,4 +16,9 @@ type OptionsWithTZ = { awareOfUnicodeTokens?: boolean, } -declare module.exports: (date: Date | number, timeZone: string, options?: OptionsWithTZ) => string +declare module.exports: ( + date: Date | string | number, + timeZone: string, + formatStr: string, + options?: OptionsWithTZ +) => string diff --git a/src/fp/formatInTimeZone/index.js b/src/fp/formatInTimeZone/index.js index 95c0baa..98584d5 100644 --- a/src/fp/formatInTimeZone/index.js +++ b/src/fp/formatInTimeZone/index.js @@ -3,6 +3,6 @@ import fn from '../../formatInTimeZone/index.js' import convertToFP from 'date-fns/fp/_lib/convertToFP/index.js' -var formatInTimeZone = convertToFP(fn, 2) +var formatInTimeZone = convertToFP(fn, 3) export default formatInTimeZone diff --git a/src/fp/formatInTimeZone/index.js.flow b/src/fp/formatInTimeZone/index.js.flow index 7e88a5c..bb3ffeb 100644 --- a/src/fp/formatInTimeZone/index.js.flow +++ b/src/fp/formatInTimeZone/index.js.flow @@ -20,4 +20,10 @@ type CurriedFn1 = (a: A) => R type CurriedFn2 = (a: A) => CurriedFn1 | ((a: A, b: B) => R) -declare module.exports: CurriedFn2 +type CurriedFn3 = ( + a: A +) => + | CurriedFn2 + | ((a: A, b: B) => CurriedFn1 | ((a: A, b: B, c: C) => R)) + +declare module.exports: CurriedFn3 diff --git a/src/fp/formatInTimeZoneWithOptions/index.js b/src/fp/formatInTimeZoneWithOptions/index.js index eda1d8d..69b1289 100644 --- a/src/fp/formatInTimeZoneWithOptions/index.js +++ b/src/fp/formatInTimeZoneWithOptions/index.js @@ -3,6 +3,6 @@ import fn from '../../formatInTimeZone/index.js' import convertToFP from 'date-fns/fp/_lib/convertToFP/index.js' -var formatInTimeZoneWithOptions = convertToFP(fn, 3) +var formatInTimeZoneWithOptions = convertToFP(fn, 4) export default formatInTimeZoneWithOptions diff --git a/src/fp/formatInTimeZoneWithOptions/index.js.flow b/src/fp/formatInTimeZoneWithOptions/index.js.flow index af469ff..d37f376 100644 --- a/src/fp/formatInTimeZoneWithOptions/index.js.flow +++ b/src/fp/formatInTimeZoneWithOptions/index.js.flow @@ -26,4 +26,19 @@ type CurriedFn3 = ( | CurriedFn2 | ((a: A, b: B) => CurriedFn1 | ((a: A, b: B, c: C) => R)) -declare module.exports: CurriedFn3 +type CurriedFn4 = ( + a: A +) => + | CurriedFn3 + | (( + a: A, + b: B + ) => + | CurriedFn2 + | (( + a: A, + b: B, + c: C + ) => CurriedFn1 | ((a: A, b: B, c: C, d: D) => R))) + +declare module.exports: CurriedFn4 diff --git a/src/fp/index.js.flow b/src/fp/index.js.flow index 43c4771..8900c29 100644 --- a/src/fp/index.js.flow +++ b/src/fp/index.js.flow @@ -43,8 +43,14 @@ type CurriedFn4 = ( declare module.exports: { format: CurriedFn2, - formatInTimeZone: CurriedFn2, - formatInTimeZoneWithOptions: CurriedFn3, + formatInTimeZone: CurriedFn3, + formatInTimeZoneWithOptions: CurriedFn4< + OptionsWithTZ, + string, + string, + Date | string | number, + string + >, formatWithOptions: CurriedFn3, getTimezoneOffset: CurriedFn2, toDate: CurriedFn1, diff --git a/src/index.js.flow b/src/index.js.flow index 11d599e..f678ef3 100644 --- a/src/index.js.flow +++ b/src/index.js.flow @@ -19,7 +19,12 @@ type OptionsWithTZ = { declare module.exports: { format: (date: Date | string | number, format: string, options?: OptionsWithTZ) => string, - formatInTimeZone: (date: Date | number, timeZone: string, options?: OptionsWithTZ) => string, + formatInTimeZone: ( + date: Date | string | number, + timeZone: string, + formatStr: string, + options?: OptionsWithTZ + ) => string, getTimezoneOffset: (timeZone: string, date?: Date | number) => number, diff --git a/typings.d.ts b/typings.d.ts index a4602d2..4d05673 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -49,7 +49,12 @@ declare module 'date-fns-tz' { function format(date: Date | string | number, format: string, options?: OptionsWithTZ): string namespace format {} - function formatInTimeZone(date: Date | number, timeZone: string, options?: OptionsWithTZ): string + function formatInTimeZone( + date: Date | string | number, + timeZone: string, + formatStr: string, + options?: OptionsWithTZ + ): string namespace formatInTimeZone {} function getTimezoneOffset(timeZone: string, date?: Date | number): number @@ -171,10 +176,16 @@ declare module 'date-fns-tz/fp' { const format: CurriedFn2 namespace format {} - const formatInTimeZone: CurriedFn2 + const formatInTimeZone: CurriedFn3 namespace formatInTimeZone {} - const formatInTimeZoneWithOptions: CurriedFn3 + const formatInTimeZoneWithOptions: CurriedFn4< + OptionsWithTZ, + string, + string, + Date | string | number, + string + > namespace formatInTimeZoneWithOptions {} const formatWithOptions: CurriedFn3 @@ -375,7 +386,12 @@ declare module 'date-fns-tz/esm' { function format(date: Date | string | number, format: string, options?: OptionsWithTZ): string namespace format {} - function formatInTimeZone(date: Date | number, timeZone: string, options?: OptionsWithTZ): string + function formatInTimeZone( + date: Date | string | number, + timeZone: string, + formatStr: string, + options?: OptionsWithTZ + ): string namespace formatInTimeZone {} function getTimezoneOffset(timeZone: string, date?: Date | number): number @@ -497,10 +513,16 @@ declare module 'date-fns-tz/esm/fp' { const format: CurriedFn2 namespace format {} - const formatInTimeZone: CurriedFn2 + const formatInTimeZone: CurriedFn3 namespace formatInTimeZone {} - const formatInTimeZoneWithOptions: CurriedFn3 + const formatInTimeZoneWithOptions: CurriedFn4< + OptionsWithTZ, + string, + string, + Date | string | number, + string + > namespace formatInTimeZoneWithOptions {} const formatWithOptions: CurriedFn3