chain.d.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import { DateArray, UnitOfTime } from '../types';
  2. import { Locale, LocaleData } from '../locale/locale.class';
  3. import { DateParsingConfig } from '../create/parsing.types';
  4. import { CalendarSpec } from '../moment/calendar';
  5. import { Duration } from '../duration/constructor';
  6. export declare type DateInput = string | number | Date | string[] | DateArray | MomentInputObject;
  7. export declare const moment: MomentFn;
  8. export interface MomentFn {
  9. (input?: DateInput | Khronos, format?: string | string[], localeKey?: string | boolean, strict?: boolean, isUTC?: boolean): Khronos;
  10. ISO_8601: string;
  11. RFC_2822: string;
  12. utc(input?: DateInput | Khronos, format?: string | string[], localeKey?: string | boolean, strict?: boolean): Khronos;
  13. parseZone(input?: DateInput | Khronos, format?: string | string[], localeKey?: string | boolean, strict?: boolean): Khronos;
  14. unix(num: number): Khronos;
  15. locale(key?: string | string[], values?: LocaleData): string;
  16. duration(inp?: Duration | DateInput | Khronos, unit?: MomentUnitOfTime): Duration;
  17. defineLocale(name: string, config?: LocaleData): Locale;
  18. parseTwoDigitYear(input: string): number;
  19. isDate(input?: any): input is Date;
  20. months(): string[];
  21. months(index: number): string;
  22. months(format: string): string[];
  23. months(format: string, index: number): string;
  24. monthsShort(): string[];
  25. monthsShort(index: number): string;
  26. monthsShort(format: string): string[];
  27. monthsShort(format: string, index: number): string;
  28. weekdays(): string[];
  29. weekdays(index: number): string;
  30. weekdays(format: string): string[];
  31. weekdays(format: string, index: number): string;
  32. weekdays(localeSorted: boolean): string[];
  33. weekdays(localeSorted: boolean, index: number): string;
  34. weekdays(localeSorted: boolean, format: string): string[];
  35. weekdays(localeSorted: boolean, format: string, index: number): string;
  36. weekdaysShort(): string[];
  37. weekdaysShort(index: number): string;
  38. weekdaysShort(format: string): string[];
  39. weekdaysShort(format: string, index: number): string;
  40. weekdaysShort(localeSorted: boolean): string[];
  41. weekdaysShort(localeSorted: boolean, index: number): string;
  42. weekdaysShort(localeSorted: boolean, format: string): string[];
  43. weekdaysShort(localeSorted: boolean, format: string, index: number): string;
  44. weekdaysMin(): string[];
  45. weekdaysMin(index: number): string;
  46. weekdaysMin(format: string): string[];
  47. weekdaysMin(format: string, index: number): string;
  48. weekdaysMin(localeSorted: boolean): string[];
  49. weekdaysMin(localeSorted: boolean, index: number): string;
  50. weekdaysMin(localeSorted: boolean, format: string): string[];
  51. weekdaysMin(localeSorted: boolean, format: string, index: number): string;
  52. relativeTimeThreshold(threshold: string): number | boolean;
  53. relativeTimeThreshold(threshold: string, limit: number): boolean;
  54. min(...dates: ((DateInput | Khronos)[] | (DateInput | Khronos))[]): Khronos;
  55. max(...dates: ((DateInput | Khronos)[] | (DateInput | Khronos))[]): Khronos;
  56. localeData(key?: string | string[] | Khronos): Locale;
  57. updateLocale(language: string, localeSpec?: LocaleData): Locale;
  58. calendarFormat(m: Date, now: Date): string;
  59. calendarFormat(m: Khronos, now: Khronos): string;
  60. invalid(): Khronos;
  61. locales(): string[];
  62. updateOffset(m: Khronos, keepTime?: boolean): void;
  63. }
  64. export interface MomentInputObject {
  65. years?: number;
  66. year?: number;
  67. y?: number;
  68. months?: number;
  69. month?: number;
  70. M?: number;
  71. days?: number;
  72. day?: number;
  73. d?: number;
  74. dates?: number;
  75. date?: number;
  76. D?: number;
  77. hours?: number;
  78. hour?: number;
  79. h?: number;
  80. minutes?: number;
  81. minute?: number;
  82. m?: number;
  83. seconds?: number;
  84. second?: number;
  85. s?: number;
  86. milliseconds?: number;
  87. millisecond?: number;
  88. ms?: number;
  89. w?: number;
  90. week?: number;
  91. weeks?: number;
  92. Q?: number;
  93. quarter?: number;
  94. quarters?: number;
  95. weekYear?: number;
  96. }
  97. export declare type MomentUnitOfTime = ('year' | 'years' | 'y' | 'month' | 'months' | 'M' | 'week' | 'weeks' | 'w' | 'day' | 'days' | 'd' | 'hour' | 'hours' | 'h' | 'minute' | 'minutes' | 'm' | 'second' | 'seconds' | 's' | 'millisecond' | 'milliseconds' | 'ms' | 'q' | 'quarter' | 'quarters' | 'Q' | 'isoWeek' | 'isoWeeks' | 'W' | 'date' | 'dates' | 'D');
  98. export declare type MomentAll = MomentUnitOfTime | 'weekYear' | 'weekYears' | 'gg' | 'isoWeekYear' | 'isoWeekYears' | 'GG' | 'dayOfYear' | 'dayOfYears' | 'DDD' | 'weekday' | 'weekdays' | 'e' | 'isoWeekday' | 'isoWeekdays' | 'E';
  99. export declare class Khronos {
  100. _date: Date;
  101. _isUTC: boolean;
  102. _isStrict: boolean;
  103. _locale: Locale;
  104. _format: string | string[];
  105. _offset: number;
  106. _tzm: number;
  107. constructor(input?: DateInput, format?: string | string[], localeKey?: string, strict?: boolean, isUTC?: boolean, offset?: number);
  108. _toConfig(): DateParsingConfig;
  109. locale(): string;
  110. locale(localeKey: string | string[] | Khronos): Khronos;
  111. localeData(): Locale;
  112. add(val: number | string | MomentInputObject, period?: UnitOfTime | MomentUnitOfTime): Khronos;
  113. calendar(time?: DateInput | Khronos, formats?: CalendarSpec): string;
  114. clone(): Khronos;
  115. diff(b: DateInput | Khronos, unitOfTime?: MomentUnitOfTime, precise?: boolean): number;
  116. endOf(period?: MomentUnitOfTime): Khronos;
  117. format(format?: string): string;
  118. from(time?: DateInput | Khronos, withoutSuffix?: boolean): string;
  119. fromNow(withoutSuffix?: boolean): string;
  120. to(inp: DateInput | Khronos, suffix?: boolean): string;
  121. toNow(withoutPrefix?: boolean): string;
  122. subtract(val: number | string | MomentInputObject, period?: UnitOfTime | MomentUnitOfTime): Khronos;
  123. get(period: MomentAll): number;
  124. set(period: MomentAll | MomentInputObject, input?: number): Khronos;
  125. toString(): string;
  126. toISOString(): string;
  127. inspect(): string;
  128. toJSON(): string;
  129. toDate(): Date;
  130. toObject(): {
  131. [key in MomentUnitOfTime]?: number;
  132. };
  133. toArray(): DateArray;
  134. isAfter(date: Khronos, unit?: MomentUnitOfTime): boolean;
  135. isBefore(date: Khronos, unit?: MomentUnitOfTime): boolean;
  136. isBetween(from: Khronos, to: Khronos, unit?: MomentUnitOfTime, inclusivity?: string): boolean;
  137. isSame(date: Khronos, unit?: MomentUnitOfTime): boolean;
  138. isSameOrAfter(date: Khronos, unit?: MomentUnitOfTime): boolean;
  139. isSameOrBefore(date: Khronos, unit?: MomentUnitOfTime): boolean;
  140. isValid(): boolean;
  141. valueOf(): number;
  142. unix(): number;
  143. utcOffset(): number;
  144. utcOffset(b: number | string, keepLocalTime?: boolean): Khronos;
  145. utc(keepLocalTime?: boolean): Khronos;
  146. local(keepLocalTime?: boolean): Khronos;
  147. parseZone(input?: string): Khronos;
  148. hasAlignedHourOffset(input?: Khronos): boolean;
  149. isDST(): boolean;
  150. isLocal(): boolean;
  151. isUtcOffset(): boolean;
  152. isUTC(): boolean;
  153. isUtc(): boolean;
  154. zoneAbbr(): string;
  155. zoneName(): string;
  156. year(): number;
  157. year(year: number): Khronos;
  158. weekYear(): number;
  159. weekYear(val: number): Khronos;
  160. isoWeekYear(): number;
  161. isoWeekYear(val: number): Khronos;
  162. isLeapYear(): boolean;
  163. month(): number;
  164. month(month: number | string): Khronos;
  165. /** @deprecated */
  166. hour(): number;
  167. hour(hours: number): Khronos;
  168. hours(): number;
  169. hours(hours: number): Khronos;
  170. /** @deprecated */
  171. minute(): number;
  172. minute(minutes: number): Khronos;
  173. minutes(): number;
  174. minutes(minutes: number): Khronos;
  175. /** @deprecated */
  176. second(): number;
  177. second(seconds: number): Khronos;
  178. seconds(): number;
  179. seconds(seconds: number): Khronos;
  180. /** @deprecated */
  181. millisecond(): number;
  182. millisecond(ms: number): Khronos;
  183. milliseconds(): number;
  184. milliseconds(seconds: number): Khronos;
  185. date(): number;
  186. date(date: number): Khronos;
  187. day(): number;
  188. day(input: number | string): Khronos;
  189. weekday(): number;
  190. weekday(val: number): Khronos;
  191. isoWeekday(): number;
  192. isoWeekday(val: number | string): Khronos;
  193. dayOfYear(): number;
  194. dayOfYear(val: number): Khronos;
  195. week(): number;
  196. week(input: number): Khronos;
  197. /** @deprecated */
  198. weeks(): number;
  199. weeks(input: number): Khronos;
  200. isoWeek(): number;
  201. isoWeek(val: number): Khronos;
  202. /** @deprecated */
  203. isoWeeks(): number;
  204. isoWeeks(val: number): Khronos;
  205. weeksInYear(): number;
  206. isoWeeksInYear(): number;
  207. daysInMonth(): number;
  208. quarter(): number;
  209. quarter(val: number): Khronos;
  210. /** @deprecated */
  211. quarters(): number;
  212. quarters(val: number): Khronos;
  213. startOf(period?: MomentUnitOfTime): Khronos;
  214. }