UNPKG

1.7 kBTypeScriptView Raw
1import { LiquidDate } from './liquid-date';
2/**
3 * A date implementation with timezone info, just like Ruby date
4 *
5 * Implementation:
6 * - create a Date offset by it's timezone difference, avoiding overriding a bunch of methods
7 * - rewrite getTimezoneOffset() to trick strftime
8 */
9export declare class TimezoneDate implements LiquidDate {
10 private timezoneOffset;
11 private timezoneName;
12 private date;
13 private displayDate;
14 constructor(init: string | number | Date | TimezoneDate, timezone: number | string);
15 getTime(): number;
16 getMilliseconds(): number;
17 getSeconds(): number;
18 getMinutes(): number;
19 getHours(): number;
20 getDay(): number;
21 getDate(): number;
22 getMonth(): number;
23 getFullYear(): number;
24 toLocaleString(locale?: string, init?: any): string;
25 toLocaleTimeString(locale?: string): string;
26 toLocaleDateString(locale?: string): string;
27 getTimezoneOffset(): number;
28 getTimezoneName(): string;
29 /**
30 * Create a Date object fixed to it's declared Timezone. Both
31 * - 2021-08-06T02:29:00.000Z and
32 * - 2021-08-06T02:29:00.000+08:00
33 * will always be displayed as
34 * - 2021-08-06 02:29:00
35 * regardless timezoneOffset in JavaScript realm
36 *
37 * The implementation hack:
38 * Instead of calling `.getMonth()`/`.getUTCMonth()` respect to `preserveTimezones`,
39 * we create a different Date to trick strftime, it's both simpler and more performant.
40 * Given that a template is expected to be parsed fewer times than rendered.
41 */
42 static createDateFixedToTimezone(dateString: string): LiquidDate;
43 private static getTimezoneOffset;
44}