bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/annotate/web/static/js/typings/browser/definitions/moment/moment.d.ts (about) 1 // Compiled using typings@0.6.8 2 // Source: https://raw.githubusercontent.com/typed-typings/npm-moment/a4075cd50e63efbedd850f654594f293ab81a385/moment.d.ts 3 declare module 'moment/moment' { 4 // Type definitions for Moment.js 2.10.5 5 6 function moment(): moment.Moment; 7 function moment(date: number): moment.Moment; 8 function moment(date: number[]): moment.Moment; 9 function moment(date: string, format?: string, strict?: boolean): moment.Moment; 10 function moment(date: string, format?: string, language?: string, strict?: boolean): moment.Moment; 11 function moment(date: string, formats: string[], strict?: boolean): moment.Moment; 12 function moment(date: string, formats: string[], language?: string, strict?: boolean): moment.Moment; 13 function moment(date: string, specialFormat: () => void, strict?: boolean): moment.Moment; 14 function moment(date: string, specialFormat: () => void, language?: string, strict?: boolean): moment.Moment; 15 function moment(date: string, formatsIncludingSpecial: any[], strict?: boolean): moment.Moment; 16 function moment(date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): moment.Moment; 17 function moment(date: Date): moment.Moment; 18 function moment(date: moment.Moment): moment.Moment; 19 function moment(date: Object): moment.Moment; 20 21 namespace moment { 22 type formatFunction = () => string; 23 24 interface MomentDateObject { 25 years?: number; 26 /* One digit */ 27 months?: number; 28 /* Day of the month */ 29 date?: number; 30 hours?: number; 31 minutes?: number; 32 seconds?: number; 33 milliseconds?: number; 34 } 35 36 interface MomentLanguageData extends BaseMomentLanguage { 37 /** 38 * @param formatType should be L, LL, LLL, LLLL. 39 */ 40 longDateFormat(formatType: string): string; 41 } 42 43 interface Duration { 44 humanize(withSuffix?: boolean): string; 45 46 as(units: string): number; 47 48 milliseconds(): number; 49 asMilliseconds(): number; 50 51 seconds(): number; 52 asSeconds(): number; 53 54 minutes(): number; 55 asMinutes(): number; 56 57 hours(): number; 58 asHours(): number; 59 60 days(): number; 61 asDays(): number; 62 63 months(): number; 64 asMonths(): number; 65 66 years(): number; 67 asYears(): number; 68 69 add(n: number, p: string): Duration; 70 add(n: number): Duration; 71 add(d: Duration): Duration; 72 73 subtract(n: number, p: string): Duration; 74 subtract(n: number): Duration; 75 subtract(d: Duration): Duration; 76 77 toISOString(): string; 78 toJSON(): string; 79 } 80 81 interface MomentInput { 82 /** Year */ 83 years?: number; 84 /** Year */ 85 year?: number; 86 /** Year */ 87 y?: number; 88 89 /** Month */ 90 months?: number; 91 /** Month */ 92 month?: number; 93 /** Month */ 94 M?: number; 95 96 /** Week */ 97 weeks?: number; 98 /** Week */ 99 week?: number; 100 /** Week */ 101 w?: number; 102 103 /** Day/Date */ 104 days?: number; 105 /** Day/Date */ 106 day?: number; 107 /** Day/Date */ 108 date?: number; 109 /** Day/Date */ 110 d?: number; 111 112 /** Hour */ 113 hours?: number; 114 /** Hour */ 115 hour?: number; 116 /** Hour */ 117 h?: number; 118 119 /** Minute */ 120 minutes?: number; 121 /** Minute */ 122 minute?: number; 123 /** Minute */ 124 m?: number; 125 126 /** Second */ 127 seconds?: number; 128 /** Second */ 129 second?: number; 130 /** Second */ 131 s?: number; 132 133 /** Millisecond */ 134 milliseconds?: number; 135 /** Millisecond */ 136 millisecond?: number; 137 /** Millisecond */ 138 ms?: number; 139 } 140 141 interface MomentCalendar { 142 lastDay?: string | formatFunction; 143 sameDay?: string | formatFunction; 144 nextDay?: string | formatFunction; 145 lastWeek?: string | formatFunction; 146 nextWeek?: string | formatFunction; 147 sameElse?: string | formatFunction; 148 } 149 150 interface MomentRelativeTime { 151 future: any; 152 past: any; 153 s: any; 154 m: any; 155 mm: any; 156 h: any; 157 hh: any; 158 d: any; 159 dd: any; 160 M: any; 161 MM: any; 162 y: any; 163 yy: any; 164 } 165 166 interface MomentLongDateFormat { 167 L: string; 168 LL: string; 169 LLL: string; 170 LLLL: string; 171 LT: string; 172 LTS: string; 173 l?: string; 174 ll?: string; 175 lll?: string; 176 llll?: string; 177 lt?: string; 178 lts?: string; 179 } 180 181 interface BaseMomentLanguage { 182 months?: any; 183 monthsShort?: any; 184 weekdays?: any; 185 weekdaysShort?: any; 186 weekdaysMin?: any; 187 relativeTime?: MomentRelativeTime; 188 meridiem?: (hour: number, minute: number, isLowercase: boolean) => string; 189 calendar?: MomentCalendar; 190 ordinal?: (num: number) => string; 191 } 192 193 interface MomentLanguage extends BaseMomentLanguage { 194 longDateFormat?: MomentLongDateFormat; 195 } 196 197 interface Moment { 198 format(format: string): string; 199 format(): string; 200 201 fromNow(withoutSuffix?: boolean): string; 202 203 startOf(unitOfTime: string): Moment; 204 endOf(unitOfTime: string): Moment; 205 206 /** 207 * Mutates the original moment by adding time. (deprecated in 2.8.0) 208 * 209 * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 210 * @param amount the amount you want to add 211 */ 212 add(unitOfTime: string, amount: number): Moment; 213 /** 214 * Mutates the original moment by adding time. 215 * 216 * @param amount the amount you want to add 217 * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 218 */ 219 add(amount: number, unitOfTime: string): Moment; 220 /** 221 * Mutates the original moment by adding time. Note that the order of arguments can be flipped. 222 * 223 * @param amount the amount you want to add 224 * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 225 */ 226 add(amount: string, unitOfTime: string): Moment; 227 /** 228 * Mutates the original moment by adding time. 229 * 230 * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} 231 */ 232 add(objectLiteral: MomentInput): Moment; 233 /** 234 * Mutates the original moment by adding time. 235 * 236 * @param duration a length of time 237 */ 238 add(duration: Duration): Moment; 239 240 /** 241 * Mutates the original moment by subtracting time. (deprecated in 2.8.0) 242 * 243 * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 244 * @param amount the amount you want to subtract 245 */ 246 subtract(unitOfTime: string, amount: number): Moment; 247 /** 248 * Mutates the original moment by subtracting time. 249 * 250 * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 251 * @param amount the amount you want to subtract 252 */ 253 subtract(amount: number, unitOfTime: string): Moment; 254 /** 255 * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. 256 * 257 * @param amount the amount you want to add 258 * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 259 */ 260 subtract(amount: string, unitOfTime: string): Moment; 261 /** 262 * Mutates the original moment by subtracting time. 263 * 264 * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} 265 */ 266 subtract(objectLiteral: MomentInput): Moment; 267 /** 268 * Mutates the original moment by subtracting time. 269 * 270 * @param duration a length of time 271 */ 272 subtract(duration: Duration): Moment; 273 274 calendar(): string; 275 calendar(start: Moment): string; 276 calendar(start: Moment, formats: MomentCalendar): string; 277 278 clone(): Moment; 279 280 /** 281 * @return Unix timestamp, or milliseconds since the epoch. 282 */ 283 valueOf(): number; 284 285 local(): Moment; // current date/time in local mode 286 287 utc(): Moment; // current date/time in UTC mode 288 289 isValid(): boolean; 290 invalidAt(): number; 291 292 year(y: number): Moment; 293 year(): number; 294 quarter(): number; 295 quarter(q: number): Moment; 296 month(M: number): Moment; 297 month(M: string): Moment; 298 month(): number; 299 day(d: number): Moment; 300 day(d: string): Moment; 301 day(): number; 302 date(d: number): Moment; 303 date(): number; 304 hour(h: number): Moment; 305 hour(): number; 306 hours(h: number): Moment; 307 hours(): number; 308 minute(m: number): Moment; 309 minute(): number; 310 minutes(m: number): Moment; 311 minutes(): number; 312 second(s: number): Moment; 313 second(): number; 314 seconds(s: number): Moment; 315 seconds(): number; 316 millisecond(ms: number): Moment; 317 millisecond(): number; 318 milliseconds(ms: number): Moment; 319 milliseconds(): number; 320 weekday(): number; 321 weekday(d: number): Moment; 322 isoWeekday(): number; 323 isoWeekday(d: number): Moment; 324 weekYear(): number; 325 weekYear(d: number): Moment; 326 isoWeekYear(): number; 327 isoWeekYear(d: number): Moment; 328 week(): number; 329 week(d: number): Moment; 330 weeks(): number; 331 weeks(d: number): Moment; 332 isoWeek(): number; 333 isoWeek(d: number): Moment; 334 isoWeeks(): number; 335 isoWeeks(d: number): Moment; 336 weeksInYear(): number; 337 isoWeeksInYear(): number; 338 dayOfYear(): number; 339 dayOfYear(d: number): Moment; 340 341 from(f: Moment | string | number | Date | number[], suffix?: boolean): string; 342 to(f: Moment | string | number | Date | number[], suffix?: boolean): string; 343 toNow(withoutPrefix?: boolean): string; 344 345 diff(b: Moment): number; 346 diff(b: Moment, unitOfTime: string): number; 347 diff(b: Moment, unitOfTime: string, round: boolean): number; 348 349 toArray(): number[]; 350 toDate(): Date; 351 toISOString(): string; 352 toJSON(): string; 353 unix(): number; 354 355 isLeapYear(): boolean; 356 zone(): number; 357 zone(b: number): Moment; 358 zone(b: string): Moment; 359 utcOffset(): number; 360 utcOffset(b: number): Moment; 361 utcOffset(b: string): Moment; 362 daysInMonth(): number; 363 isDST(): boolean; 364 365 isBefore(): boolean; 366 isBefore(b: Moment | string | number | Date | number[], granularity?: string): boolean; 367 368 isAfter(): boolean; 369 isAfter(b: Moment | string | number | Date | number[], granularity?: string): boolean; 370 371 isSame(b: Moment | string | number | Date | number[], granularity?: string): boolean; 372 isBetween(a: Moment | string | number | Date | number[], b: Moment | string | number | Date | number[], granularity?: string): boolean; 373 374 // Deprecated as of 2.8.0. 375 lang(language: string): Moment; 376 lang(reset: boolean): Moment; 377 lang(): MomentLanguage; 378 379 locale(language: string): Moment; 380 locale(reset: boolean): Moment; 381 locale(): string; 382 383 localeData(language: string): Moment; 384 localeData(reset: boolean): Moment; 385 localeData(): MomentLanguage; 386 387 // Deprecated as of 2.7.0. 388 max(date: Moment | string | number | Date | any[]): Moment; 389 max(date: string, format: string): Moment; 390 391 // Deprecated as of 2.7.0. 392 min(date: Moment | string | number | Date | any[]): Moment; 393 min(date: string, format: string): Moment; 394 395 get(unit: string): number; 396 set(unit: string, value: number): Moment; 397 set(objectLiteral: MomentInput): Moment; 398 399 /*This returns an object containing year, month, day-of-month, hour, minute, seconds, milliseconds.*/ 400 //Works with version 2.10.5+ 401 toObject(): MomentDateObject; 402 } 403 404 export var version: string; 405 export var fn: Moment; 406 407 export function utc(): Moment; 408 export function utc(date: number): Moment; 409 export function utc(date: number[]): Moment; 410 export function utc(date: string, format?: string, strict?: boolean): Moment; 411 export function utc(date: string, format?: string, language?: string, strict?: boolean): Moment; 412 export function utc(date: string, formats: string[], strict?: boolean): Moment; 413 export function utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; 414 export function utc(date: Date): Moment; 415 export function utc(date: Moment): Moment; 416 export function utc(date: Object): Moment; 417 418 export function unix(timestamp: number): Moment; 419 420 export function invalid(parsingFlags?: Object): Moment; 421 export function isMoment(): boolean; 422 export function isMoment(m: any): boolean; 423 export function isDate(m: any): boolean; 424 export function isDuration(): boolean; 425 export function isDuration(d: any): boolean; 426 427 // Deprecated in 2.8.0. 428 export function lang(language?: string): string; 429 export function lang(language?: string, definition?: MomentLanguage): string; 430 431 export function locale(language?: string): string; 432 export function locale(language?: string[]): string; 433 export function locale(language?: string, definition?: MomentLanguage): string; 434 435 export function localeData(language?: string): MomentLanguageData; 436 437 export var longDateFormat: any; 438 export var relativeTime: any; 439 export var meridiem: (hour: number, minute: number, isLowercase: boolean) => string; 440 export var calendar: any; 441 export var ordinal: (num: number) => string; 442 443 export function duration(milliseconds: Number): Duration; 444 export function duration(num: Number, unitOfTime: string): Duration; 445 export function duration(input: MomentInput): Duration; 446 export function duration(object: any): Duration; 447 export function duration(): Duration; 448 449 export function parseZone(date: string): Moment; 450 451 export function months(): string[]; 452 export function months(index: number): string; 453 export function months(format: string): string[]; 454 export function months(format: string, index: number): string; 455 export function monthsShort(): string[]; 456 export function monthsShort(index: number): string; 457 export function monthsShort(format: string): string[]; 458 export function monthsShort(format: string, index: number): string; 459 460 export function weekdays(): string[]; 461 export function weekdays(index: number): string; 462 export function weekdays(format: string): string[]; 463 export function weekdays(format: string, index: number): string; 464 export function weekdaysShort(): string[]; 465 export function weekdaysShort(index: number): string; 466 export function weekdaysShort(format: string): string[]; 467 export function weekdaysShort(format: string, index: number): string; 468 export function weekdaysMin(): string[]; 469 export function weekdaysMin(index: number): string; 470 export function weekdaysMin(format: string): string[]; 471 export function weekdaysMin(format: string, index: number): string; 472 473 export function min(...moments: Moment[]): Moment; 474 export function max(...moments: Moment[]): Moment; 475 476 export function normalizeUnits(unit: string): string; 477 export function relativeTimeThreshold(threshold: string): number | boolean; 478 export function relativeTimeThreshold(threshold: string, limit: number): boolean; 479 480 /** 481 * Constant used to enable explicit ISO_8601 format parsing. 482 */ 483 export function ISO_8601(): void; 484 485 export var defaultFormat: string; 486 } 487 488 export = moment; 489 } 490 declare module 'moment' { 491 import main = require('moment/moment'); 492 export = main; 493 }