UNPKG

2.29 kBTypeScriptView Raw
1import { getCurrentTimezone } from "./getTimezone";
2import { TimePrecision } from "./timePrecision";
3import { UTC_TIME } from "./timezoneItems";
4export { getCurrentTimezone, UTC_TIME };
5export declare function getIsoEquivalentWithUpdatedTimezone(date: Date, timezone: string, timePrecision: TimePrecision | undefined): string;
6/**
7 * HACKHACK: this method relies on parsing strings with the `Date()` constructor, which is discouraged
8 * by the MDN documentation and the Moment.js status page. If we continue to use this approach, we need
9 * to validate that input strings conform to the ISO 8601 format.
10 *
11 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#parameters
12 * @see https://momentjs.com/docs/#/-project-status/
13 *
14 * @param value ISO string representation of a date
15 * @param timezone target timezone IANA code
16 */
17export declare function getDateObjectFromIsoString(value: string | undefined, timezone: string): Date | undefined;
18export declare function getDateObjectFromIsoString(value: string | null | undefined, timezone: string): Date | null | undefined;
19/**
20 * Converts a date in local timezone to represent better the passed through timezone
21 * representation for the user, meaning if 8 AM local time is currently the date, and local time is Oslo
22 * and the user has a default of UTC in selection, the new date should represent 7 AM.
23 *
24 * @param date the current existing date object
25 * @param newTimezone the new timezone that we need to update the date to represent
26 * @returns The date converted to match the new timezone
27 */
28export declare function convertLocalDateToTimezoneTime(date: Date, newTimezone: string): Date;
29/**
30 * Converts a date to match a new timezone selection. The date is the internal local time
31 * representation for the user, meaning if 8 AM local time is currently selected, and local time is Oslo
32 * and the user switches timezone to UTC, the new date should represent 9 AM in Oslo time.
33 *
34 * @param date the current existing date object
35 * @param newTimezone the new timezone that the date should be converted to represent
36 * @returns The date converted to match the new timezone
37 */
38export declare function convertDateToLocalEquivalentOfTimezoneTime(date: Date, newTimezone: string): Date;