moment.d.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. /**
  2. * @param strict Strict parsing disables the deprecated fallback to the native Date constructor when
  3. * parsing a string.
  4. */
  5. declare function moment(inp?: moment.MomentInput, strict?: boolean): moment.Moment;
  6. /**
  7. * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
  8. * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
  9. * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
  10. */
  11. declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSpecification, strict?: boolean): moment.Moment;
  12. /**
  13. * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
  14. * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
  15. * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
  16. */
  17. declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSpecification, language?: string, strict?: boolean): moment.Moment;
  18. declare namespace moment {
  19. type RelativeTimeKey = 's' | 'ss' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'w' | 'ww' | 'M' | 'MM' | 'y' | 'yy';
  20. type CalendarKey = 'sameDay' | 'nextDay' | 'lastDay' | 'nextWeek' | 'lastWeek' | 'sameElse' | string;
  21. type LongDateFormatKey = 'LTS' | 'LT' | 'L' | 'LL' | 'LLL' | 'LLLL' | 'lts' | 'lt' | 'l' | 'll' | 'lll' | 'llll';
  22. interface Locale {
  23. calendar(key?: CalendarKey, m?: Moment, now?: Moment): string;
  24. longDateFormat(key: LongDateFormatKey): string;
  25. invalidDate(): string;
  26. ordinal(n: number): string;
  27. preparse(inp: string): string;
  28. postformat(inp: string): string;
  29. relativeTime(n: number, withoutSuffix: boolean,
  30. key: RelativeTimeKey, isFuture: boolean): string;
  31. pastFuture(diff: number, absRelTime: string): string;
  32. set(config: Object): void;
  33. months(): string[];
  34. months(m: Moment, format?: string): string;
  35. monthsShort(): string[];
  36. monthsShort(m: Moment, format?: string): string;
  37. monthsParse(monthName: string, format: string, strict: boolean): number;
  38. monthsRegex(strict: boolean): RegExp;
  39. monthsShortRegex(strict: boolean): RegExp;
  40. week(m: Moment): number;
  41. firstDayOfYear(): number;
  42. firstDayOfWeek(): number;
  43. weekdays(): string[];
  44. weekdays(m: Moment, format?: string): string;
  45. weekdaysMin(): string[];
  46. weekdaysMin(m: Moment): string;
  47. weekdaysShort(): string[];
  48. weekdaysShort(m: Moment): string;
  49. weekdaysParse(weekdayName: string, format: string, strict: boolean): number;
  50. weekdaysRegex(strict: boolean): RegExp;
  51. weekdaysShortRegex(strict: boolean): RegExp;
  52. weekdaysMinRegex(strict: boolean): RegExp;
  53. isPM(input: string): boolean;
  54. meridiem(hour: number, minute: number, isLower: boolean): string;
  55. }
  56. interface StandaloneFormatSpec {
  57. format: string[];
  58. standalone: string[];
  59. isFormat?: RegExp;
  60. }
  61. interface WeekSpec {
  62. dow: number;
  63. doy?: number;
  64. }
  65. type CalendarSpecVal = string | ((m?: MomentInput, now?: Moment) => string);
  66. interface CalendarSpec {
  67. sameDay?: CalendarSpecVal;
  68. nextDay?: CalendarSpecVal;
  69. lastDay?: CalendarSpecVal;
  70. nextWeek?: CalendarSpecVal;
  71. lastWeek?: CalendarSpecVal;
  72. sameElse?: CalendarSpecVal;
  73. // any additional properties might be used with moment.calendarFormat
  74. [x: string]: CalendarSpecVal | undefined;
  75. }
  76. type RelativeTimeSpecVal = (
  77. string |
  78. ((n: number, withoutSuffix: boolean,
  79. key: RelativeTimeKey, isFuture: boolean) => string)
  80. );
  81. type RelativeTimeFuturePastVal = string | ((relTime: string) => string);
  82. interface RelativeTimeSpec {
  83. future?: RelativeTimeFuturePastVal;
  84. past?: RelativeTimeFuturePastVal;
  85. s?: RelativeTimeSpecVal;
  86. ss?: RelativeTimeSpecVal;
  87. m?: RelativeTimeSpecVal;
  88. mm?: RelativeTimeSpecVal;
  89. h?: RelativeTimeSpecVal;
  90. hh?: RelativeTimeSpecVal;
  91. d?: RelativeTimeSpecVal;
  92. dd?: RelativeTimeSpecVal;
  93. w?: RelativeTimeSpecVal;
  94. ww?: RelativeTimeSpecVal;
  95. M?: RelativeTimeSpecVal;
  96. MM?: RelativeTimeSpecVal;
  97. y?: RelativeTimeSpecVal;
  98. yy?: RelativeTimeSpecVal;
  99. }
  100. interface LongDateFormatSpec {
  101. LTS: string;
  102. LT: string;
  103. L: string;
  104. LL: string;
  105. LLL: string;
  106. LLLL: string;
  107. // lets forget for a sec that any upper/lower permutation will also work
  108. lts?: string;
  109. lt?: string;
  110. l?: string;
  111. ll?: string;
  112. lll?: string;
  113. llll?: string;
  114. }
  115. type MonthWeekdayFn = (momentToFormat: Moment, format?: string) => string;
  116. type WeekdaySimpleFn = (momentToFormat: Moment) => string;
  117. interface LocaleSpecification {
  118. months?: string[] | StandaloneFormatSpec | MonthWeekdayFn;
  119. monthsShort?: string[] | StandaloneFormatSpec | MonthWeekdayFn;
  120. weekdays?: string[] | StandaloneFormatSpec | MonthWeekdayFn;
  121. weekdaysShort?: string[] | StandaloneFormatSpec | WeekdaySimpleFn;
  122. weekdaysMin?: string[] | StandaloneFormatSpec | WeekdaySimpleFn;
  123. meridiemParse?: RegExp;
  124. meridiem?: (hour: number, minute:number, isLower: boolean) => string;
  125. isPM?: (input: string) => boolean;
  126. longDateFormat?: LongDateFormatSpec;
  127. calendar?: CalendarSpec;
  128. relativeTime?: RelativeTimeSpec;
  129. invalidDate?: string;
  130. ordinal?: (n: number) => string;
  131. ordinalParse?: RegExp;
  132. week?: WeekSpec;
  133. // Allow anything: in general any property that is passed as locale spec is
  134. // put in the locale object so it can be used by locale functions
  135. [x: string]: any;
  136. }
  137. interface MomentObjectOutput {
  138. years: number;
  139. /* One digit */
  140. months: number;
  141. /* Day of the month */
  142. date: number;
  143. hours: number;
  144. minutes: number;
  145. seconds: number;
  146. milliseconds: number;
  147. }
  148. interface argThresholdOpts {
  149. ss?: number;
  150. s?: number;
  151. m?: number;
  152. h?: number;
  153. d?: number;
  154. w?: number | null;
  155. M?: number;
  156. }
  157. interface Duration {
  158. clone(): Duration;
  159. humanize(argWithSuffix?: boolean, argThresholds?: argThresholdOpts): string;
  160. humanize(argThresholds?: argThresholdOpts): string;
  161. abs(): Duration;
  162. as(units: unitOfTime.Base): number;
  163. get(units: unitOfTime.Base): number;
  164. milliseconds(): number;
  165. asMilliseconds(): number;
  166. seconds(): number;
  167. asSeconds(): number;
  168. minutes(): number;
  169. asMinutes(): number;
  170. hours(): number;
  171. asHours(): number;
  172. days(): number;
  173. asDays(): number;
  174. weeks(): number;
  175. asWeeks(): number;
  176. months(): number;
  177. asMonths(): number;
  178. years(): number;
  179. asYears(): number;
  180. add(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration;
  181. subtract(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration;
  182. locale(): string;
  183. locale(locale: LocaleSpecifier): Duration;
  184. localeData(): Locale;
  185. toISOString(): string;
  186. toJSON(): string;
  187. isValid(): boolean;
  188. /**
  189. * @deprecated since version 2.8.0
  190. */
  191. lang(locale: LocaleSpecifier): Moment;
  192. /**
  193. * @deprecated since version 2.8.0
  194. */
  195. lang(): Locale;
  196. /**
  197. * @deprecated
  198. */
  199. toIsoString(): string;
  200. }
  201. interface MomentRelativeTime {
  202. future: any;
  203. past: any;
  204. s: any;
  205. ss: any;
  206. m: any;
  207. mm: any;
  208. h: any;
  209. hh: any;
  210. d: any;
  211. dd: any;
  212. M: any;
  213. MM: any;
  214. y: any;
  215. yy: any;
  216. }
  217. interface MomentLongDateFormat {
  218. L: string;
  219. LL: string;
  220. LLL: string;
  221. LLLL: string;
  222. LT: string;
  223. LTS: string;
  224. l?: string;
  225. ll?: string;
  226. lll?: string;
  227. llll?: string;
  228. lt?: string;
  229. lts?: string;
  230. }
  231. interface MomentParsingFlags {
  232. empty: boolean;
  233. unusedTokens: string[];
  234. unusedInput: string[];
  235. overflow: number;
  236. charsLeftOver: number;
  237. nullInput: boolean;
  238. invalidMonth: string | null;
  239. invalidFormat: boolean;
  240. userInvalidated: boolean;
  241. iso: boolean;
  242. parsedDateParts: any[];
  243. meridiem: string | null;
  244. }
  245. interface MomentParsingFlagsOpt {
  246. empty?: boolean;
  247. unusedTokens?: string[];
  248. unusedInput?: string[];
  249. overflow?: number;
  250. charsLeftOver?: number;
  251. nullInput?: boolean;
  252. invalidMonth?: string;
  253. invalidFormat?: boolean;
  254. userInvalidated?: boolean;
  255. iso?: boolean;
  256. parsedDateParts?: any[];
  257. meridiem?: string | null;
  258. }
  259. interface MomentBuiltinFormat {
  260. __momentBuiltinFormatBrand: any;
  261. }
  262. type MomentFormatSpecification = string | MomentBuiltinFormat | (string | MomentBuiltinFormat)[];
  263. namespace unitOfTime {
  264. type Base = (
  265. "year" | "years" | "y" |
  266. "month" | "months" | "M" |
  267. "week" | "weeks" | "w" |
  268. "day" | "days" | "d" |
  269. "hour" | "hours" | "h" |
  270. "minute" | "minutes" | "m" |
  271. "second" | "seconds" | "s" |
  272. "millisecond" | "milliseconds" | "ms"
  273. );
  274. type _quarter = "quarter" | "quarters" | "Q";
  275. type _isoWeek = "isoWeek" | "isoWeeks" | "W";
  276. type _date = "date" | "dates" | "D";
  277. type DurationConstructor = Base | _quarter;
  278. type DurationAs = Base;
  279. type StartOf = Base | _quarter | _isoWeek | _date | null;
  280. type Diff = Base | _quarter;
  281. type MomentConstructor = Base | _date;
  282. type All = Base | _quarter | _isoWeek | _date |
  283. "weekYear" | "weekYears" | "gg" |
  284. "isoWeekYear" | "isoWeekYears" | "GG" |
  285. "dayOfYear" | "dayOfYears" | "DDD" |
  286. "weekday" | "weekdays" | "e" |
  287. "isoWeekday" | "isoWeekdays" | "E";
  288. }
  289. interface MomentInputObject {
  290. years?: number;
  291. year?: number;
  292. y?: number;
  293. months?: number;
  294. month?: number;
  295. M?: number;
  296. days?: number;
  297. day?: number;
  298. d?: number;
  299. dates?: number;
  300. date?: number;
  301. D?: number;
  302. hours?: number;
  303. hour?: number;
  304. h?: number;
  305. minutes?: number;
  306. minute?: number;
  307. m?: number;
  308. seconds?: number;
  309. second?: number;
  310. s?: number;
  311. milliseconds?: number;
  312. millisecond?: number;
  313. ms?: number;
  314. }
  315. interface DurationInputObject extends MomentInputObject {
  316. quarters?: number;
  317. quarter?: number;
  318. Q?: number;
  319. weeks?: number;
  320. week?: number;
  321. w?: number;
  322. }
  323. interface MomentSetObject extends MomentInputObject {
  324. weekYears?: number;
  325. weekYear?: number;
  326. gg?: number;
  327. isoWeekYears?: number;
  328. isoWeekYear?: number;
  329. GG?: number;
  330. quarters?: number;
  331. quarter?: number;
  332. Q?: number;
  333. weeks?: number;
  334. week?: number;
  335. w?: number;
  336. isoWeeks?: number;
  337. isoWeek?: number;
  338. W?: number;
  339. dayOfYears?: number;
  340. dayOfYear?: number;
  341. DDD?: number;
  342. weekdays?: number;
  343. weekday?: number;
  344. e?: number;
  345. isoWeekdays?: number;
  346. isoWeekday?: number;
  347. E?: number;
  348. }
  349. interface FromTo {
  350. from: MomentInput;
  351. to: MomentInput;
  352. }
  353. type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | null | undefined;
  354. type DurationInputArg1 = Duration | number | string | FromTo | DurationInputObject | null | undefined;
  355. type DurationInputArg2 = unitOfTime.DurationConstructor;
  356. type LocaleSpecifier = string | Moment | Duration | string[] | boolean;
  357. interface MomentCreationData {
  358. input: MomentInput;
  359. format?: MomentFormatSpecification;
  360. locale: Locale;
  361. isUTC: boolean;
  362. strict?: boolean;
  363. }
  364. interface Moment extends Object {
  365. format(format?: string): string;
  366. startOf(unitOfTime: unitOfTime.StartOf): Moment;
  367. endOf(unitOfTime: unitOfTime.StartOf): Moment;
  368. add(amount?: DurationInputArg1, unit?: DurationInputArg2): Moment;
  369. /**
  370. * @deprecated reverse syntax
  371. */
  372. add(unit: unitOfTime.DurationConstructor, amount: number|string): Moment;
  373. subtract(amount?: DurationInputArg1, unit?: DurationInputArg2): Moment;
  374. /**
  375. * @deprecated reverse syntax
  376. */
  377. subtract(unit: unitOfTime.DurationConstructor, amount: number|string): Moment;
  378. calendar(): string;
  379. calendar(formats: CalendarSpec): string;
  380. calendar(time?: MomentInput, formats?: CalendarSpec): string;
  381. clone(): Moment;
  382. /**
  383. * @return Unix timestamp in milliseconds
  384. */
  385. valueOf(): number;
  386. // current date/time in local mode
  387. local(keepLocalTime?: boolean): Moment;
  388. isLocal(): boolean;
  389. // current date/time in UTC mode
  390. utc(keepLocalTime?: boolean): Moment;
  391. isUTC(): boolean;
  392. /**
  393. * @deprecated use isUTC
  394. */
  395. isUtc(): boolean;
  396. parseZone(): Moment;
  397. isValid(): boolean;
  398. invalidAt(): number;
  399. hasAlignedHourOffset(other?: MomentInput): boolean;
  400. creationData(): MomentCreationData;
  401. parsingFlags(): MomentParsingFlags;
  402. year(y: number): Moment;
  403. year(): number;
  404. /**
  405. * @deprecated use year(y)
  406. */
  407. years(y: number): Moment;
  408. /**
  409. * @deprecated use year()
  410. */
  411. years(): number;
  412. quarter(): number;
  413. quarter(q: number): Moment;
  414. quarters(): number;
  415. quarters(q: number): Moment;
  416. month(M: number|string): Moment;
  417. month(): number;
  418. /**
  419. * @deprecated use month(M)
  420. */
  421. months(M: number|string): Moment;
  422. /**
  423. * @deprecated use month()
  424. */
  425. months(): number;
  426. day(d: number|string): Moment;
  427. day(): number;
  428. days(d: number|string): Moment;
  429. days(): number;
  430. date(d: number): Moment;
  431. date(): number;
  432. /**
  433. * @deprecated use date(d)
  434. */
  435. dates(d: number): Moment;
  436. /**
  437. * @deprecated use date()
  438. */
  439. dates(): number;
  440. hour(h: number): Moment;
  441. hour(): number;
  442. hours(h: number): Moment;
  443. hours(): number;
  444. minute(m: number): Moment;
  445. minute(): number;
  446. minutes(m: number): Moment;
  447. minutes(): number;
  448. second(s: number): Moment;
  449. second(): number;
  450. seconds(s: number): Moment;
  451. seconds(): number;
  452. millisecond(ms: number): Moment;
  453. millisecond(): number;
  454. milliseconds(ms: number): Moment;
  455. milliseconds(): number;
  456. weekday(): number;
  457. weekday(d: number): Moment;
  458. isoWeekday(): number;
  459. isoWeekday(d: number|string): Moment;
  460. weekYear(): number;
  461. weekYear(d: number): Moment;
  462. isoWeekYear(): number;
  463. isoWeekYear(d: number): Moment;
  464. week(): number;
  465. week(d: number): Moment;
  466. weeks(): number;
  467. weeks(d: number): Moment;
  468. isoWeek(): number;
  469. isoWeek(d: number): Moment;
  470. isoWeeks(): number;
  471. isoWeeks(d: number): Moment;
  472. weeksInYear(): number;
  473. isoWeeksInYear(): number;
  474. isoWeeksInISOWeekYear(): number;
  475. dayOfYear(): number;
  476. dayOfYear(d: number): Moment;
  477. from(inp: MomentInput, suffix?: boolean): string;
  478. to(inp: MomentInput, suffix?: boolean): string;
  479. fromNow(withoutSuffix?: boolean): string;
  480. toNow(withoutPrefix?: boolean): string;
  481. diff(b: MomentInput, unitOfTime?: unitOfTime.Diff, precise?: boolean): number;
  482. toArray(): number[];
  483. toDate(): Date;
  484. toISOString(keepOffset?: boolean): string;
  485. inspect(): string;
  486. toJSON(): string;
  487. unix(): number;
  488. isLeapYear(): boolean;
  489. /**
  490. * @deprecated in favor of utcOffset
  491. */
  492. zone(): number;
  493. zone(b: number|string): Moment;
  494. utcOffset(): number;
  495. utcOffset(b: number|string, keepLocalTime?: boolean): Moment;
  496. isUtcOffset(): boolean;
  497. daysInMonth(): number;
  498. isDST(): boolean;
  499. zoneAbbr(): string;
  500. zoneName(): string;
  501. isBefore(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean;
  502. isAfter(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean;
  503. isSame(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean;
  504. isSameOrAfter(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean;
  505. isSameOrBefore(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean;
  506. isBetween(a: MomentInput, b: MomentInput, granularity?: unitOfTime.StartOf, inclusivity?: "()" | "[)" | "(]" | "[]"): boolean;
  507. /**
  508. * @deprecated as of 2.8.0, use locale
  509. */
  510. lang(language: LocaleSpecifier): Moment;
  511. /**
  512. * @deprecated as of 2.8.0, use locale
  513. */
  514. lang(): Locale;
  515. locale(): string;
  516. locale(locale: LocaleSpecifier): Moment;
  517. localeData(): Locale;
  518. /**
  519. * @deprecated no reliable implementation
  520. */
  521. isDSTShifted(): boolean;
  522. // NOTE(constructor): Same as moment constructor
  523. /**
  524. * @deprecated as of 2.7.0, use moment.min/max
  525. */
  526. max(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment;
  527. /**
  528. * @deprecated as of 2.7.0, use moment.min/max
  529. */
  530. max(inp?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
  531. // NOTE(constructor): Same as moment constructor
  532. /**
  533. * @deprecated as of 2.7.0, use moment.min/max
  534. */
  535. min(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment;
  536. /**
  537. * @deprecated as of 2.7.0, use moment.min/max
  538. */
  539. min(inp?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
  540. get(unit: unitOfTime.All): number;
  541. set(unit: unitOfTime.All, value: number): Moment;
  542. set(objectLiteral: MomentSetObject): Moment;
  543. toObject(): MomentObjectOutput;
  544. }
  545. export var version: string;
  546. export var fn: Moment;
  547. // NOTE(constructor): Same as moment constructor
  548. /**
  549. * @param strict Strict parsing disables the deprecated fallback to the native Date constructor when
  550. * parsing a string.
  551. */
  552. export function utc(inp?: MomentInput, strict?: boolean): Moment;
  553. /**
  554. * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
  555. * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
  556. * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
  557. */
  558. export function utc(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment;
  559. /**
  560. * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
  561. * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
  562. * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
  563. */
  564. export function utc(inp?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
  565. export function unix(timestamp: number): Moment;
  566. export function invalid(flags?: MomentParsingFlagsOpt): Moment;
  567. export function isMoment(m: any): m is Moment;
  568. export function isDate(m: any): m is Date;
  569. export function isDuration(d: any): d is Duration;
  570. /**
  571. * @deprecated in 2.8.0
  572. */
  573. export function lang(language?: string): string;
  574. /**
  575. * @deprecated in 2.8.0
  576. */
  577. export function lang(language?: string, definition?: Locale): string;
  578. export function locale(language?: string): string;
  579. export function locale(language?: string[]): string;
  580. export function locale(language?: string, definition?: LocaleSpecification | null | undefined): string;
  581. export function localeData(key?: string | string[]): Locale;
  582. export function duration(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration;
  583. // NOTE(constructor): Same as moment constructor
  584. export function parseZone(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment;
  585. export function parseZone(inp?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
  586. export function months(): string[];
  587. export function months(index: number): string;
  588. export function months(format: string): string[];
  589. export function months(format: string, index: number): string;
  590. export function monthsShort(): string[];
  591. export function monthsShort(index: number): string;
  592. export function monthsShort(format: string): string[];
  593. export function monthsShort(format: string, index: number): string;
  594. export function weekdays(): string[];
  595. export function weekdays(index: number): string;
  596. export function weekdays(format: string): string[];
  597. export function weekdays(format: string, index: number): string;
  598. export function weekdays(localeSorted: boolean): string[];
  599. export function weekdays(localeSorted: boolean, index: number): string;
  600. export function weekdays(localeSorted: boolean, format: string): string[];
  601. export function weekdays(localeSorted: boolean, format: string, index: number): string;
  602. export function weekdaysShort(): string[];
  603. export function weekdaysShort(index: number): string;
  604. export function weekdaysShort(format: string): string[];
  605. export function weekdaysShort(format: string, index: number): string;
  606. export function weekdaysShort(localeSorted: boolean): string[];
  607. export function weekdaysShort(localeSorted: boolean, index: number): string;
  608. export function weekdaysShort(localeSorted: boolean, format: string): string[];
  609. export function weekdaysShort(localeSorted: boolean, format: string, index: number): string;
  610. export function weekdaysMin(): string[];
  611. export function weekdaysMin(index: number): string;
  612. export function weekdaysMin(format: string): string[];
  613. export function weekdaysMin(format: string, index: number): string;
  614. export function weekdaysMin(localeSorted: boolean): string[];
  615. export function weekdaysMin(localeSorted: boolean, index: number): string;
  616. export function weekdaysMin(localeSorted: boolean, format: string): string[];
  617. export function weekdaysMin(localeSorted: boolean, format: string, index: number): string;
  618. export function min(moments: Moment[]): Moment;
  619. export function min(...moments: Moment[]): Moment;
  620. export function max(moments: Moment[]): Moment;
  621. export function max(...moments: Moment[]): Moment;
  622. /**
  623. * Returns unix time in milliseconds. Overwrite for profit.
  624. */
  625. export function now(): number;
  626. export function defineLocale(language: string, localeSpec: LocaleSpecification | null): Locale;
  627. export function updateLocale(language: string, localeSpec: LocaleSpecification | null): Locale;
  628. export function locales(): string[];
  629. export function normalizeUnits(unit: unitOfTime.All): string;
  630. export function relativeTimeThreshold(threshold: string): number | boolean;
  631. export function relativeTimeThreshold(threshold: string, limit: number): boolean;
  632. export function relativeTimeRounding(fn: (num: number) => number): boolean;
  633. export function relativeTimeRounding(): (num: number) => number;
  634. export function calendarFormat(m: Moment, now: Moment): string;
  635. export function parseTwoDigitYear(input: string): number;
  636. /**
  637. * Constant used to enable explicit ISO_8601 format parsing.
  638. */
  639. export var ISO_8601: MomentBuiltinFormat;
  640. export var RFC_2822: MomentBuiltinFormat;
  641. export var defaultFormat: string;
  642. export var defaultFormatUtc: string;
  643. export var suppressDeprecationWarnings: boolean;
  644. export var deprecationHandler: ((name: string | null, msg: string) => void) | null | undefined;
  645. export var HTML5_FMT: {
  646. DATETIME_LOCAL: string,
  647. DATETIME_LOCAL_SECONDS: string,
  648. DATETIME_LOCAL_MS: string,
  649. DATE: string,
  650. TIME: string,
  651. TIME_SECONDS: string,
  652. TIME_MS: string,
  653. WEEK: string,
  654. MONTH: string
  655. };
  656. }
  657. export = moment;
  658. export as namespace moment;