@hebcal/hdate
Version:
converts between Hebrew and Gregorian dates using Rata Die (R.D.) algorithm by Dershowitz and Reingold
35 lines (34 loc) • 1.62 kB
TypeScript
/**
* Returns a string similar to `Date.toISOString()` but in the
* timezone `tzid`. Contrary to the typical meaning of `Z` at the end
* of the string, this is not actually a UTC date.
* @example
* const dt = new Date(Date.UTC(2021, 0, 31, 7, 30, 50));
* getPseudoISO('UTC', dt); // '2021-01-31T07:30:50Z'
* getPseudoISO('America/New_York', dt); // '2021-01-31T02:30:50Z'
* getPseudoISO('Asia/Jerusalem', dt); // '2021-01-31T09:30:50Z'
*/
export declare function getPseudoISO(tzid: string, date: Date): string;
/**
* Returns number of minutes `tzid` is offset from UTC on date `date`.
* @example
* const january = new Date(Date.UTC(2020, 0, 15, 12));
* getTimezoneOffset('America/New_York', january); // 300 (UTC-5)
* getTimezoneOffset('America/Los_Angeles', january); // 480 (UTC-8)
* getTimezoneOffset('Asia/Jerusalem', january); // -120 (UTC+2)
*/
export declare function getTimezoneOffset(tzid: string, date: Date): number;
/**
* Formats the date portion of `dt` as `YYYY-MM-DD` using the date's
* local-time fields (year/month/day), not its UTC fields. The year is
* always padded to at least 4 digits and negative years are prefixed
* with `-`, matching the formatting that `pad4` applies.
*
* This is intentionally separate from `Date.prototype.toISOString()`,
* which always reports in UTC and may report a different day for
* dates near midnight in non-UTC time zones.
* @example
* isoDateString(new Date(2008, 10, 13)); // '2008-11-13'
* isoDateString(new Date(2021, 0, 31)); // '2021-01-31'
*/
export declare function isoDateString(dt: Date): string;