index.d.ts 3.0 KB

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