UNPKG

1.6 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 date;
12 private displayDate;
13 constructor(init: string | number | Date | TimezoneDate, timezoneOffset: number);
14 getTime(): number;
15 getMilliseconds(): number;
16 getSeconds(): number;
17 getMinutes(): number;
18 getHours(): number;
19 getDay(): number;
20 getDate(): number;
21 getMonth(): number;
22 getFullYear(): number;
23 toLocaleString(locale?: string, init?: any): string;
24 toLocaleTimeString(locale?: string): string;
25 toLocaleDateString(locale?: string): string;
26 getTimezoneOffset(): number;
27 /**
28 * Create a Date object fixed to it's declared Timezone. Both
29 * - 2021-08-06T02:29:00.000Z and
30 * - 2021-08-06T02:29:00.000+08:00
31 * will always be displayed as
32 * - 2021-08-06 02:29:00
33 * regardless timezoneOffset in JavaScript realm
34 *
35 * The implementation hack:
36 * Instead of calling `.getMonth()`/`.getUTCMonth()` respect to `preserveTimezones`,
37 * we create a different Date to trick strftime, it's both simpler and more performant.
38 * Given that a template is expected to be parsed fewer times than rendered.
39 */
40 static createDateFixedToTimezone(dateString: string): LiquidDate;
41}