UNPKG

3.09 kBTypeScriptView Raw
1// Type definitions for moment-timezone.js 0.5
2// Project: http://momentjs.com/timezone/
3// Definitions by: Michel Salib <https://github.com/michelsalib>
4// Alan Brazil Lins <https://github.com/alanblins>
5// Agustin Carrasco <https://github.com/asermax>
6// Borys Kupar <https://github.com/borys-kupar>
7// Anthony Rainer <https://github.com/pristinesource>
8// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
9// Migrated here from DefinitelyTyped in release moment-timezone@0.5.30
10
11import moment = require('moment');
12
13declare module 'moment' {
14 interface MomentZone {
15 name: string;
16 abbrs: string[];
17 untils: number[];
18 offsets: number[];
19 population: number;
20
21 abbr(timestamp: number): string;
22 offset(timestamp: number): number;
23 utcOffset(timestamp: number): number;
24 parse(timestamp: number): number;
25 }
26
27 interface MomentZoneOffset {
28 name: string;
29 offset: number;
30 }
31
32 interface MomentTimezone {
33 (): moment.Moment;
34 (timezone: string): moment.Moment;
35 (date: number, timezone: string): moment.Moment;
36 (date: number[], timezone: string): moment.Moment;
37 (date: string, timezone: string): moment.Moment;
38 (date: string, format: moment.MomentFormatSpecification, timezone: string): moment.Moment;
39 (date: string, format: moment.MomentFormatSpecification, strict: boolean, timezone: string): moment.Moment;
40 (date: string, format: moment.MomentFormatSpecification, language: string, timezone: string): moment.Moment;
41 (date: string, format: moment.MomentFormatSpecification, language: string, strict: boolean, timezone: string): moment.Moment;
42 (date: Date, timezone: string): moment.Moment;
43 (date: moment.Moment, timezone: string): moment.Moment;
44 (date: any, timezone: string): moment.Moment;
45
46 zone(timezone: string): MomentZone | null;
47
48 add(packedZoneString: string): void;
49 add(packedZoneString: string[]): void;
50
51 link(packedLinkString: string): void;
52 link(packedLinkString: string[]): void;
53
54 load(data: { version: string; links: string[]; zones: string[] }): void;
55
56 names(): string[];
57 zonesForCountry<T extends true>(country: string, with_offset: T): T extends true ? MomentZoneOffset[] : never;
58 zonesForCountry<T extends false>(country: string, with_offset?: T): T extends false ? string[] : never;
59 zonesForCountry(country: string, with_offset?: boolean): MomentZoneOffset[] | string[];
60 countries(): string[];
61 guess(ignoreCache?: boolean): string;
62
63 setDefault(timezone?: string): Moment;
64 dataVersion: string;
65 }
66
67 interface Moment {
68 tz(): string | undefined;
69 tz(timezone: string, keepLocalTime?: boolean): moment.Moment;
70 zoneAbbr(): string;
71 zoneName(): string;
72 }
73
74 const tz: MomentTimezone;
75}
76
77// require("moment-timezone") === require("moment")
78export = moment;