moment-timezone-utils.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import moment = require('moment');
  2. import { MomentTimezone } from "./index";
  3. declare module 'moment' {
  4. /** Parsed / unpacked zone data. */
  5. interface UnpackedZone {
  6. /** The uniquely identifying name of the time zone. */
  7. name: string;
  8. /** zone abbreviations */
  9. abbrs: Array<string>;
  10. /** (measured in milliseconds) */
  11. untils: Array<number | null>;
  12. /** (measured in minutes) */
  13. offsets: Array<number>;
  14. }
  15. /** Bundle of zone data and links for multiple timezones */
  16. interface PackedZoneBundle {
  17. version: string;
  18. zones: Array<string>;
  19. links: Array<string>;
  20. }
  21. /** Bundle of zone data and links for multiple timezones */
  22. interface UnpackedZoneBundle {
  23. version: string;
  24. zones: Array<UnpackedZone>;
  25. links: Array<string>;
  26. }
  27. /** extends MomentTimezone declared in index */
  28. interface MomentTimezone {
  29. /** Converts zone data in the unpacked format to the packed format. */
  30. pack(unpackedObject: UnpackedZone): string;
  31. /** Convert a base 10 number to a base 60 string. */
  32. packBase60(input: number, precision?: number): string;
  33. /** Create links out of two zones that share data.
  34. * @returns A new ZoneBundle with duplicate zone data replaced by links
  35. */
  36. createLinks(unlinked: UnpackedZoneBundle): PackedZoneBundle;
  37. /**
  38. * Filter out data for years outside a certain range.
  39. * @return a new, filtered UnPackedZone object
  40. */
  41. filterYears(unpackedZone: UnpackedZone, startYear: number, endYear: number): UnpackedZone;
  42. /**
  43. * Filter out data for years outside a certain range.
  44. * @return a new, filtered UnPackedZone object
  45. */
  46. filterYears(unpackedZone: UnpackedZone, startAndEndYear: number): UnpackedZone;
  47. /**
  48. * Combines packing, link creation, and subsetting of years into one simple interface.
  49. * Pass in an unpacked bundle, start year, and end year and get a filtered, linked, packed bundle back.
  50. */
  51. filterLinkPack(unpackedBundle: UnpackedZoneBundle, startYear: number, endYear: number): PackedZoneBundle;
  52. /**
  53. * Combines packing, link creation, and subsetting of years into one simple interface.
  54. * Pass in an unpacked bundle, start year, and end year and get a filtered, linked, packed bundle back.
  55. */
  56. filterLinkPack(unpackedBundle: UnpackedZoneBundle, startAndEndYear: number): PackedZoneBundle;
  57. }
  58. }
  59. // require("moment-timezone") === require("moment")
  60. export = moment;