UNPKG

temporal-fns

Version:

A utility library for working with JavaScript Temporal objects, providing helper functions for date and time manipulations.

36 lines (21 loc) 2.1 kB
import { Temporal } from 'temporal-polyfill'; type DayOfWeek = 1 | 2 | 3 | 4 | 5 | 6 | 7; declare function endOfDay<T extends Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T): T; interface EndOfMonthOptions { preserveTime?: boolean; } declare function endOfMonth<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T, options?: EndOfMonthOptions): T; declare function endOfWeek<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T): T; declare function firstDayOfWeekOfMonth<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T, dayOfWeek: DayOfWeek): T; declare function fromDate(date: Date): Temporal.Instant; declare function lastDayOfWeekOfMonth<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T, dayOfWeek: DayOfWeek): T; declare function nextDayOfWeek<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T, dayOfWeek: DayOfWeek): T; declare function previousDayOfWeek<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T, dayOfWeek: DayOfWeek): T; declare function startOfDay<T extends Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T): T; interface StartOfMonthOptions { preserveTime?: boolean; } declare function startOfMonth<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T, options?: StartOfMonthOptions): T; declare function startOfWeek<T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T): T; declare function toDate<T extends Temporal.Instant | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime>(temporal: T): Date; export { type DayOfWeek, type EndOfMonthOptions, type StartOfMonthOptions, endOfDay, endOfMonth, endOfWeek, firstDayOfWeekOfMonth, fromDate, lastDayOfWeekOfMonth, nextDayOfWeek, previousDayOfWeek, startOfDay, startOfMonth, startOfWeek, toDate };