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