vremel
Version:
JavaScript date utility library for Temporal API
30 lines • 1.84 kB
TypeScript
import { UTCDate } from "@date-fns/utc";
import type { GenericDateConstructor, Temporal } from "../types.js";
/**
* Returns `Date` which represents clock (local) time of given temporal object,
* dropping timezone and calendar information.
* When you pass `ZonedDateTime`, clock time will be unchanged but exact time will change.
* This function is useful when you want to use formatting functions of [date-fns](https://date-fns.org/).
*
* @param dateTime datetime object
*/
export declare function toDateFromClockTime(dateTime: Temporal.ZonedDateTime | Temporal.PlainDate | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay): UTCDate;
/**
* Returns `Date` which represents clock (local) time of given temporal object,
* dropping timezone and calendar information.
* When you pass `ZonedDateTime`, clock time will be unchanged but exact time will change.
* This function is useful when you want to use formatting functions of [date-fns](https://date-fns.org/).
* You can pass `DateConstructor` parameter to specify a constructor to build the date to return,
* but passing JavaScript's `Date` is **strongly discouraged** because `Date` is a hotbed of timezone troubles.
*
* @example
* ```typescript
* import { UTCDate } from "@date-fns/utc";
* toDateFromClockTime(Temporal.Now.plainDateISO(), UTCDate);
* ```
*
* @param dateTime datetime object
* @param DateConstructor constructor of return value, `UTCDateMini` from "@date-fns/utc" as default
*/
export declare function toDateFromClockTime<DateType extends Date>(dateTime: Temporal.ZonedDateTime | Temporal.PlainDate | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay, DateConstructor: GenericDateConstructor<DateType>): DateType;
//# sourceMappingURL=toDateFromClockTime.d.ts.map