moment.d.ts 23 KB

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