marnusw/date-fns-tz

`OptionsWithTZ` type missing `useAdditionalDayOfYearTokens` and `useAdditionalWeekYearTokens` options

Closed this issue · 2 comments

The useAdditionalDayOfYearTokens and useAdditionalWeekYearTokens options are included in tests, but not included in typings.d.ts:

date-fns-tz/typings.d.ts

Lines 30 to 42 in a92e0ad

export type OptionsWithTZ = {
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7
additionalDigits?: 0 | 1 | 2
timeZone?: string
locale?: Locale
includeSeconds?: boolean
addSuffix?: boolean
unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year'
roundingMethod?: 'floor' | 'ceil' | 'round'
awareOfUnicodeTokens?: boolean
}
}

From date-fns documentation on Unicode Tokens:

...format and parse functions won't accept these tokens without useAdditionalDayOfYearTokens option for D and DD and useAdditionalWeekYearTokens options for YY and YYYY:

format(new Date(), 'D', { useAdditionalDayOfYearTokens: true })
//=> '283'

parse('365+1987', 'DD+YYYY', new Date(), {
  useAdditionalDayOfYearTokens: true,
  useAdditionalWeekYearTokens: true
}).toString()
//=> 'Wed Dec 31 1986 00:00:00 GMT+0200 (EET)'

This should be fixed in 3.1.0 which inherits the options types from date-fns.

Yup, all reporting good and well now. Thanks for the fix!