index.d.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. // Generated by typings
  2. // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/637e7d6df755e785387d5269cb9287cdc51b8cb7/moment/moment.d.ts
  3. declare namespace moment {
  4. type MomentComparable = Moment | string | number | Date | number[];
  5. interface MomentDateObject {
  6. years?: number;
  7. /* One digit */
  8. months?: number;
  9. /* Day of the month */
  10. date?: number;
  11. hours?: number;
  12. minutes?: number;
  13. seconds?: number;
  14. milliseconds?: number;
  15. }
  16. interface MomentInput {
  17. /** Year */
  18. years?: number;
  19. /** Year */
  20. year?: number;
  21. /** Year */
  22. y?: number;
  23. /** Month */
  24. months?: number;
  25. /** Month */
  26. month?: number;
  27. /** Month */
  28. M?: number;
  29. /** Week */
  30. weeks?: number;
  31. /** Week */
  32. week?: number;
  33. /** Week */
  34. w?: number;
  35. /** Day/Date */
  36. days?: number;
  37. /** Day/Date */
  38. day?: number;
  39. /** Day/Date */
  40. date?: number;
  41. /** Day/Date */
  42. d?: number;
  43. /** Hour */
  44. hours?: number;
  45. /** Hour */
  46. hour?: number;
  47. /** Hour */
  48. h?: number;
  49. /** Minute */
  50. minutes?: number;
  51. /** Minute */
  52. minute?: number;
  53. /** Minute */
  54. m?: number;
  55. /** Second */
  56. seconds?: number;
  57. /** Second */
  58. second?: number;
  59. /** Second */
  60. s?: number;
  61. /** Millisecond */
  62. milliseconds?: number;
  63. /** Millisecond */
  64. millisecond?: number;
  65. /** Millisecond */
  66. ms?: number;
  67. }
  68. interface Duration {
  69. humanize(withSuffix?: boolean): string;
  70. as(units: string): number;
  71. milliseconds(): number;
  72. asMilliseconds(): number;
  73. seconds(): number;
  74. asSeconds(): number;
  75. minutes(): number;
  76. asMinutes(): number;
  77. hours(): number;
  78. asHours(): number;
  79. days(): number;
  80. asDays(): number;
  81. weeks(): number;
  82. asWeeks(): number;
  83. months(): number;
  84. asMonths(): number;
  85. years(): number;
  86. asYears(): number;
  87. add(n: number, p: string): Duration;
  88. add(n: number): Duration;
  89. add(d: Duration): Duration;
  90. subtract(n: number, p: string): Duration;
  91. subtract(n: number): Duration;
  92. subtract(d: Duration): Duration;
  93. toISOString(): string;
  94. toJSON(): string;
  95. }
  96. interface MomentLocale {
  97. ordinal(n: number): string;
  98. }
  99. interface MomentCreationData {
  100. input?: string;
  101. format?: string;
  102. locale: MomentLocale;
  103. isUTC: boolean;
  104. strict?: boolean;
  105. }
  106. interface Moment {
  107. format(format: string): string;
  108. format(): string;
  109. fromNow(withoutSuffix?: boolean): string;
  110. startOf(unitOfTime: string): Moment;
  111. endOf(unitOfTime: string): Moment;
  112. /**
  113. * Mutates the original moment by adding time. (deprecated in 2.8.0)
  114. *
  115. * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
  116. * @param amount the amount you want to add
  117. */
  118. add(unitOfTime: string, amount: number): Moment;
  119. /**
  120. * Mutates the original moment by adding time.
  121. *
  122. * @param amount the amount you want to add
  123. * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
  124. */
  125. add(amount: number, unitOfTime: string): Moment;
  126. /**
  127. * Mutates the original moment by adding time. Note that the order of arguments can be flipped.
  128. *
  129. * @param amount the amount you want to add
  130. * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
  131. */
  132. add(amount: string, unitOfTime: string): Moment;
  133. /**
  134. * Mutates the original moment by adding time.
  135. *
  136. * @param objectLiteral an object literal that describes multiple time units {days:7,months:1}
  137. */
  138. add(objectLiteral: MomentInput): Moment;
  139. /**
  140. * Mutates the original moment by adding time.
  141. *
  142. * @param duration a length of time
  143. */
  144. add(duration: Duration): Moment;
  145. /**
  146. * Mutates the original moment by subtracting time. (deprecated in 2.8.0)
  147. *
  148. * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
  149. * @param amount the amount you want to subtract
  150. */
  151. subtract(unitOfTime: string, amount: number): Moment;
  152. /**
  153. * Mutates the original moment by subtracting time.
  154. *
  155. * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
  156. * @param amount the amount you want to subtract
  157. */
  158. subtract(amount: number, unitOfTime: string): Moment;
  159. /**
  160. * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped.
  161. *
  162. * @param amount the amount you want to add
  163. * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
  164. */
  165. subtract(amount: string, unitOfTime: string): Moment;
  166. /**
  167. * Mutates the original moment by subtracting time.
  168. *
  169. * @param objectLiteral an object literal that describes multiple time units {days:7,months:1}
  170. */
  171. subtract(objectLiteral: MomentInput): Moment;
  172. /**
  173. * Mutates the original moment by subtracting time.
  174. *
  175. * @param duration a length of time
  176. */
  177. subtract(duration: Duration): Moment;
  178. calendar(): string;
  179. calendar(start: Moment): string;
  180. calendar(start: Moment, formats: MomentCalendar): string;
  181. clone(): Moment;
  182. /**
  183. * @return Unix timestamp, or milliseconds since the epoch.
  184. */
  185. valueOf(): number;
  186. local(): Moment; // current date/time in local mode
  187. utc(): Moment; // current date/time in UTC mode
  188. isValid(): boolean;
  189. invalidAt(): number;
  190. year(y: number): Moment;
  191. year(): number;
  192. quarter(): number;
  193. quarter(q: number): Moment;
  194. month(M: number): Moment;
  195. month(M: string): Moment;
  196. month(): number;
  197. day(d: number): Moment;
  198. day(d: string): Moment;
  199. day(): number;
  200. date(d: number): Moment;
  201. date(): number;
  202. hour(h: number): Moment;
  203. hour(): number;
  204. hours(h: number): Moment;
  205. hours(): number;
  206. minute(m: number): Moment;
  207. minute(): number;
  208. minutes(m: number): Moment;
  209. minutes(): number;
  210. second(s: number): Moment;
  211. second(): number;
  212. seconds(s: number): Moment;
  213. seconds(): number;
  214. millisecond(ms: number): Moment;
  215. millisecond(): number;
  216. milliseconds(ms: number): Moment;
  217. milliseconds(): number;
  218. weekday(): number;
  219. weekday(d: number): Moment;
  220. isoWeekday(): number;
  221. isoWeekday(d: number): Moment;
  222. weekYear(): number;
  223. weekYear(d: number): Moment;
  224. isoWeekYear(): number;
  225. isoWeekYear(d: number): Moment;
  226. week(): number;
  227. week(d: number): Moment;
  228. weeks(): number;
  229. weeks(d: number): Moment;
  230. isoWeek(): number;
  231. isoWeek(d: number): Moment;
  232. isoWeeks(): number;
  233. isoWeeks(d: number): Moment;
  234. weeksInYear(): number;
  235. isoWeeksInYear(): number;
  236. dayOfYear(): number;
  237. dayOfYear(d: number): Moment;
  238. from(f: MomentComparable, suffix?: boolean): string;
  239. to(f: MomentComparable, suffix?: boolean): string;
  240. toNow(withoutPrefix?: boolean): string;
  241. diff(b: MomentComparable): number;
  242. diff(b: MomentComparable, unitOfTime: string): number;
  243. diff(b: MomentComparable, unitOfTime: string, round: boolean): number;
  244. toArray(): number[];
  245. toDate(): Date;
  246. toISOString(): string;
  247. toJSON(): string;
  248. unix(): number;
  249. isLeapYear(): boolean;
  250. zone(): number;
  251. zone(b: number): Moment;
  252. zone(b: string): Moment;
  253. utcOffset(): number;
  254. utcOffset(b: number): Moment;
  255. utcOffset(b: string): Moment;
  256. daysInMonth(): number;
  257. isDST(): boolean;
  258. isBefore(): boolean;
  259. isBefore(b: MomentComparable, granularity?: string): boolean;
  260. isAfter(): boolean;
  261. isAfter(b: MomentComparable, granularity?: string): boolean;
  262. isSame(b: MomentComparable, granularity?: string): boolean;
  263. isBetween(a: MomentComparable, b: MomentComparable, granularity?: string, inclusivity?: string): boolean;
  264. /**
  265. * @since 2.10.7+
  266. */
  267. isSameOrBefore(b: MomentComparable, granularity?: string): boolean;
  268. isSameOrAfter(b: MomentComparable, granularity?: string): boolean;
  269. /**
  270. * @deprecated since version 2.8.0
  271. */
  272. lang(language: string): Moment;
  273. lang(reset: boolean): Moment;
  274. lang(): MomentLanguage;
  275. locale(language: string): Moment;
  276. locale(reset: boolean): Moment;
  277. locale(): string;
  278. /**
  279. * @since 2.12.0+
  280. */
  281. locales() : string[];
  282. localeData(language: string): Moment;
  283. localeData(reset: boolean): Moment;
  284. localeData(): MomentLanguageData;
  285. /**
  286. * @deprecated since version 2.7.0
  287. */
  288. max(date: Moment | string | number | Date | any[]): Moment;
  289. max(date: string, format: string): Moment;
  290. /**
  291. * @deprecated since version 2.7.0
  292. */
  293. min(date: Moment | string | number | Date | any[]): Moment;
  294. min(date: string, format: string): Moment;
  295. get(unit: string): number;
  296. set(unit: string, value: number): Moment;
  297. set(objectLiteral: MomentInput): Moment;
  298. /**
  299. * This returns an object containing year, month, day-of-month, hour, minute, seconds, milliseconds.
  300. * @since 2.10.5+
  301. */
  302. toObject(): MomentDateObject;
  303. /**
  304. * @since 2.10.7+
  305. */
  306. creationData(): MomentCreationData;
  307. }
  308. type formatFunction = () => string;
  309. interface MomentCalendar {
  310. lastDay?: string | formatFunction;
  311. sameDay?: string | formatFunction;
  312. nextDay?: string | formatFunction;
  313. lastWeek?: string | formatFunction;
  314. nextWeek?: string | formatFunction;
  315. sameElse?: string | formatFunction;
  316. }
  317. interface BaseMomentLanguage {
  318. months?: any;
  319. monthsShort?: any;
  320. weekdays?: any;
  321. weekdaysShort?: any;
  322. weekdaysMin?: any;
  323. relativeTime?: MomentRelativeTime;
  324. meridiem?: (hour: number, minute: number, isLowercase: boolean) => string;
  325. calendar?: MomentCalendar;
  326. ordinal?: (num: number) => string;
  327. week?: MomentLanguageWeek;
  328. }
  329. interface MomentLanguage extends BaseMomentLanguage {
  330. longDateFormat?: MomentLongDateFormat;
  331. }
  332. interface MomentLanguageWeek {
  333. dow?: number;
  334. doy?: number;
  335. }
  336. interface MomentLanguageData {
  337. /**
  338. * Get the full localized month name of a moment object
  339. * @param {Moment} aMoment a moment object
  340. * @return {string} full month name
  341. */
  342. months(aMoment: Moment): string;
  343. /**
  344. * Get the short localized month name of a moment object
  345. * @param {Moment} aMoment a moment object
  346. * @return {string} short month name
  347. */
  348. monthsShort(aMoment: Moment): string;
  349. /**
  350. * Parses a month name and returns the month id (0-11)
  351. * @param {string} longOrShortMonthString string of month to parse
  352. * @return {number} month id (0 to 11) of input
  353. */
  354. monthsParse(longOrShortMonthString: string): number;
  355. /**
  356. * Gets the full weekday name of a moment object (eg. Monday)
  357. * @param {Moment} aMoment a moment object
  358. * @return {string} full weekday name
  359. */
  360. weekdays(aMoment: Moment): string;
  361. /**
  362. * Gets the short weekday name of a moment object (eg. Mon)
  363. * @param {Moment} aMoment a moment object
  364. * @return {string} short weekday name
  365. */
  366. weekdaysShort(aMoment: Moment): string;
  367. /**
  368. * Gets the min weekday name of a moment object (eg. Mo)
  369. * @param {Moment} aMoment a moment object
  370. * @return {string} min weekday name
  371. */
  372. weekdaysMin(aMoment: Moment): string;
  373. /**
  374. * Parses a weekday name and returns the weekday id (0-6)
  375. * @param {string} longOrShortMonthString string of weekday to parse
  376. * @return {number} weekday id (0 to 6) of input
  377. */
  378. weekdaysParse(longOrShortMonthString: string): number;
  379. /**
  380. * Returns the full format of abbreviated date-time formats
  381. * @param {string} dateFormat date-time format such as LT, L, LL and so on
  382. * @return {string} full date format string
  383. */
  384. longDateFormat(dateFormat: string): string;
  385. /**
  386. * Returns whether a string represents PM
  387. * @param {string} amPmString date string to check
  388. * @return {boolean} true if string represents PM
  389. */
  390. isPM(amPmString: string): boolean;
  391. /**
  392. * Returns am/pm string for particular time-of-day in upper/lower case
  393. * @param {number} hour hour
  394. * @param {number} minute minute
  395. * @param {boolean} isLowercase whether to return in lowercase
  396. * @return {string} 'am' or 'pm'
  397. */
  398. meridiem(hour: number, minute: number, isLowercase: boolean): string;
  399. /**
  400. * Returns a format that would be used for calendar representation.
  401. * @param {string} key one of 'sameDay', 'nextDay', 'lastDay', 'nextWeek', 'prevWeek', 'sameElse'
  402. * @param {Moment} aMoment a moment object
  403. * @return {string} date format string
  404. */
  405. calendar(key: string, aMoment: Moment): string;
  406. /**
  407. * Returns relative time string (eg. a year ago)
  408. * @param {number} number the relative number
  409. * @param {boolean} withoutSuffix whether to drop the suffix
  410. * @param {string} key one of 's', 'm', 'mm', 'h', 'hh', 'd', 'dd', 'M', 'MM', 'y', 'yy'. Single letter when number is 1.
  411. * @param {boolean} isFuture whether this represents a future date
  412. * @return {string} humanized representation of relative time
  413. */
  414. relativeTime(number: number, withoutSuffix: boolean, key: string, isFuture: boolean): string;
  415. /**
  416. * Converts relative time string to past or future string depending on difference
  417. * @param {number} diff positive or negative number
  418. * @param {string} relTime relative time string
  419. * @return {string} humanized representation of relative time
  420. */
  421. pastFuture(diff: number, relTime: string): string;
  422. /**
  423. * Convert number to ordinal string 1 -> 1st
  424. * @param {number} number the number
  425. * @return {string} ordinal string
  426. */
  427. ordinal(number: number): string;
  428. /**
  429. * Called before parsing every input string
  430. */
  431. preparse(str: string): string;
  432. /**
  433. * Called after formatting on every string
  434. */
  435. postformat(str: string): string;
  436. /**
  437. * Returns week-of-year of a moment object
  438. * @param {Moment} aMoment a moment object
  439. * @return {number} number of the week
  440. */
  441. week(aMoment: Moment): number;
  442. /**
  443. * Returns a translation of 'Invalid date'
  444. * @return {string} translation of 'Invalid date'
  445. */
  446. invalidDate(): string;
  447. /**
  448. * Returns the first day of the week (0-6, Sunday to Saturday)
  449. * @return {number} first day of the week
  450. */
  451. firstDayOfWeek(): number;
  452. /**
  453. * This and the first day of week are used to determine which is
  454. * the first week of the year. dow == 1 and doy == 4 means week starts
  455. * Monday and first week that has Thursday is the first week of the
  456. * year (but doy is NOT simply Thursday).
  457. * @return {number} number between 0-15
  458. */
  459. firstDayOfYear(): number;
  460. }
  461. interface MomentLongDateFormat {
  462. L: string;
  463. LL: string;
  464. LLL: string;
  465. LLLL: string;
  466. LT: string;
  467. LTS: string;
  468. l?: string;
  469. ll?: string;
  470. lll?: string;
  471. llll?: string;
  472. lt?: string;
  473. lts?: string;
  474. }
  475. interface MomentRelativeTime {
  476. future: any;
  477. past: any;
  478. s: any;
  479. m: any;
  480. mm: any;
  481. h: any;
  482. hh: any;
  483. d: any;
  484. dd: any;
  485. M: any;
  486. MM: any;
  487. y: any;
  488. yy: any;
  489. }
  490. interface MomentBuiltinFormat {
  491. __momentBuiltinFormatBrand: any;
  492. }
  493. type MomentFormatSpecification = string | MomentBuiltinFormat | (string | MomentBuiltinFormat)[];
  494. interface MomentStatic {
  495. version: string;
  496. fn: Moment;
  497. (): Moment;
  498. (date: number): Moment;
  499. (date: number[]): Moment;
  500. (date: string, format?: MomentFormatSpecification, strict?: boolean): Moment;
  501. (date: string, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
  502. (date: Date): Moment;
  503. (date: Moment): Moment;
  504. (date: Object): Moment;
  505. utc(): Moment;
  506. utc(date: number): Moment;
  507. utc(date: number[]): Moment;
  508. utc(date: string, format?: string, strict?: boolean): Moment;
  509. utc(date: string, format?: string, language?: string, strict?: boolean): Moment;
  510. utc(date: string, formats: string[], strict?: boolean): Moment;
  511. utc(date: string, formats: string[], language?: string, strict?: boolean): Moment;
  512. utc(date: Date): Moment;
  513. utc(date: Moment): Moment;
  514. utc(date: Object): Moment;
  515. unix(timestamp: number): Moment;
  516. invalid(parsingFlags?: Object): Moment;
  517. isMoment(): boolean;
  518. isMoment(m: any): m is Moment;
  519. isDate(m: any): m is Date;
  520. isDuration(): boolean;
  521. isDuration(d: any): d is Duration;
  522. /**
  523. * @deprecated since version 2.8.0
  524. */
  525. lang(language?: string): string;
  526. lang(language?: string, definition?: MomentLanguage): string;
  527. locale(language?: string): string;
  528. locale(language?: string[]): string;
  529. locale(language?: string, definition?: MomentLanguage): string;
  530. localeData(language?: string): MomentLanguageData;
  531. longDateFormat: any;
  532. relativeTime: any;
  533. meridiem: (hour: number, minute: number, isLowercase: boolean) => string;
  534. calendar: any;
  535. ordinal: (num: number) => string;
  536. duration(milliseconds: Number): Duration;
  537. duration(num: Number, unitOfTime: string): Duration;
  538. duration(input: MomentInput): Duration;
  539. duration(object: any): Duration;
  540. duration(): Duration;
  541. parseZone(date: string): Moment;
  542. months(): string[];
  543. months(index: number): string;
  544. months(format: string): string[];
  545. months(format: string, index: number): string;
  546. monthsShort(): string[];
  547. monthsShort(index: number): string;
  548. monthsShort(format: string): string[];
  549. monthsShort(format: string, index: number): string;
  550. weekdays(): string[];
  551. weekdays(index: number): string;
  552. weekdays(format: string): string[];
  553. weekdays(format: string, index: number): string;
  554. weekdaysShort(): string[];
  555. weekdaysShort(index: number): string;
  556. weekdaysShort(format: string): string[];
  557. weekdaysShort(format: string, index: number): string;
  558. weekdaysMin(): string[];
  559. weekdaysMin(index: number): string;
  560. weekdaysMin(format: string): string[];
  561. weekdaysMin(format: string, index: number): string;
  562. min(...moments: Moment[]): Moment;
  563. min(moments: Moment[]): Moment;
  564. max(...moments: Moment[]): Moment;
  565. max(moments: Moment[]): Moment;
  566. normalizeUnits(unit: string): string;
  567. relativeTimeThreshold(threshold: string): number | boolean;
  568. relativeTimeThreshold(threshold: string, limit: number): boolean;
  569. /**
  570. * @since 2.10.7+
  571. */
  572. now(): number;
  573. /**
  574. * Constant used to enable explicit ISO_8601 format parsing.
  575. */
  576. ISO_8601: MomentBuiltinFormat;
  577. defaultFormat: string;
  578. }
  579. }
  580. declare module 'moment' {
  581. var moment: moment.MomentStatic;
  582. export = moment;
  583. }
  584. declare module 'moment/moment' {
  585. var moment: moment.MomentStatic;
  586. export = moment;
  587. }
  588. declare var moment: moment.MomentStatic;