index.d.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import moment = require('moment');
  2. declare module 'moment' {
  3. interface MomentZone {
  4. name: string;
  5. abbrs: string[];
  6. untils: number[];
  7. offsets: number[];
  8. population: number;
  9. abbr(timestamp: number): string;
  10. offset(timestamp: number): number;
  11. utcOffset(timestamp: number): number;
  12. parse(timestamp: number): number;
  13. }
  14. interface MomentZoneOffset {
  15. name: string;
  16. offset: number;
  17. }
  18. interface MomentTimezone {
  19. (): moment.Moment;
  20. (timezone: string): moment.Moment;
  21. (date: number, timezone: string): moment.Moment;
  22. (date: number[], timezone: string): moment.Moment;
  23. (date: string, timezone: string): moment.Moment;
  24. (date: string, format: moment.MomentFormatSpecification, timezone: string): moment.Moment;
  25. (date: string, format: moment.MomentFormatSpecification, strict: boolean, timezone: string): moment.Moment;
  26. (date: string, format: moment.MomentFormatSpecification, language: string, timezone: string): moment.Moment;
  27. (date: string, format: moment.MomentFormatSpecification, language: string, strict: boolean, timezone: string): moment.Moment;
  28. (date: Date, timezone: string): moment.Moment;
  29. (date: moment.Moment, timezone: string): moment.Moment;
  30. (date: any, timezone: string): moment.Moment;
  31. zone(timezone: string): MomentZone | null;
  32. add(packedZoneString: string): void;
  33. add(packedZoneString: string[]): void;
  34. link(packedLinkString: string): void;
  35. link(packedLinkString: string[]): void;
  36. load(data: { version: string; links: string[]; zones: string[] }): void;
  37. names(): string[];
  38. zonesForCountry<T extends true>(country: string, with_offset: T): T extends true ? MomentZoneOffset[] : never;
  39. zonesForCountry<T extends false>(country: string, with_offset?: T): T extends false ? string[] : never;
  40. zonesForCountry(country: string, with_offset?: boolean): MomentZoneOffset[] | string[];
  41. countries(): string[];
  42. guess(ignoreCache?: boolean): string;
  43. setDefault(timezone?: string): Moment;
  44. }
  45. interface Moment {
  46. tz(): string | undefined;
  47. tz(timezone: string, keepLocalTime?: boolean): moment.Moment;
  48. zoneAbbr(): string;
  49. zoneName(): string;
  50. }
  51. const tz: MomentTimezone;
  52. }
  53. // require("moment-timezone") === require("moment")
  54. export = moment;