-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.d.ts
686 lines (686 loc) · 20.1 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
declare module "src/data/normalizeLocale" {
export = normalizeLocale;
/**
* Given a locale string from an operating system or process env, normalize the name
* @param {String} name A name such as fr_FR, en-US, en-us.utf-8
* @returns {String}
* @see https://github.com/sindresorhus/os-locale/blob/main/index.js for similar code
*/
function normalizeLocale(name: string): string;
}
declare module "src/data/defaultLocale" {
const _exports: string;
export = _exports;
}
declare module "src/data/twoDigitYears" {
export = twoDigitYears;
const twoDigitYears: {};
}
declare module "src/data/timezoneNames" {
export = timezoneNames;
const timezoneNames: {
'Eastern Daylight Time': number;
'Eastern Standard Time': number;
'Central Daylight Time': number;
'Central Standard Time': number;
'Mountain Daylight Time': number;
'Mountain Standard Time': number;
'Pacific Daylight Time': number;
'Pacific Standard Time': number;
ACDT: number;
ACST: number;
ACT: number;
ADT: number;
AEDT: number;
AEST: number;
AFT: number;
AKDT: number;
AKST: number;
AMST: number;
AMT: number;
ART: number;
AST: number;
AWDT: number;
AWST: number;
AZOST: number;
AZT: number;
BDT: number;
BIOT: number;
BIT: number;
BOT: number;
BRST: number;
BRT: number;
BTT: number;
CAT: number;
CCT: number;
CDT: number;
CEDT: number;
CEST: number;
CET: number;
CHADT: number;
CHAST: number;
CHOT: number;
ChST: number;
CHUT: number;
CIST: number;
CIT: number;
CKT: number;
CLST: number;
CLT: number;
COST: number;
COT: number;
CST: number;
CT: number;
CVT: number;
CXT: number;
DAVT: number;
DDUT: number;
DFT: number;
EASST: number;
EAST: number;
EAT: number;
ECT: number;
EDT: number;
EEDT: number;
EEST: number;
EET: number;
EGST: number;
EGT: number;
EIT: number;
EST: number;
FET: number;
FJT: number;
FKST: number;
FKT: number;
FNT: number;
GALT: number;
GAMT: number;
GET: number;
GFT: number;
GILT: number;
GIT: number;
GMT: number;
GST: number;
GYT: number;
HADT: number;
HAEC: number;
HAST: number;
HKT: number;
HMT: number;
HOVT: number;
HST: number;
IBST: number;
ICT: number;
IDT: number;
IOT: number;
IRDT: number;
IRKT: number;
IRST: number;
IST: number;
JST: number;
KGT: number;
KOST: number;
KRAT: number;
KST: number;
LHST: number;
LINT: number;
MAGT: number;
MART: number;
MAWT: number;
MDT: number;
MET: number;
MEST: number;
MHT: number;
MIST: number;
MIT: number;
MMT: number;
MSK: number;
MST: number;
MUT: number;
MVT: number;
MYT: number;
NCT: number;
NDT: number;
NFT: number;
NPT: number;
NST: number;
NT: number;
NUT: number;
NZDT: number;
NZST: number;
OMST: number;
ORAT: number;
PDT: number;
PET: number;
PETT: number;
PGT: number;
PHOT: number;
PKT: number;
PMDT: number;
PMST: number;
PONT: number;
PST: number;
PYST: number;
PYT: number;
RET: number;
ROTT: number;
SAKT: number;
SAMT: number;
SAST: number;
SBT: number;
SCT: number;
SGT: number;
SLST: number;
SRET: number;
SRT: number;
SST: number;
SYOT: number;
TAHT: number;
THA: number;
TFT: number;
TJT: number;
TKT: number;
TLT: number;
TMT: number;
TOT: number;
TVT: number;
UCT: number;
ULAT: number;
USZ1: number;
UTC: number;
UYST: number;
UYT: number;
UZT: number;
VET: number;
VLAT: number;
VOLT: number;
VOST: number;
VUT: number;
WAKT: number;
WAST: number;
WAT: number;
WEDT: number;
WEST: number;
WET: number;
WIT: number;
WST: number;
YAKT: number;
YEKT: number;
Z: number;
};
}
declare module "src/data/baseLookups" {
import timezoneNames = require("src/data/timezoneNames");
import twoDigitYears = require("src/data/twoDigitYears");
export const meridiem: {
am: number;
pm: number;
'a.m.': number;
'p.m.': number;
};
export namespace month {
const january: number;
const jan: number;
const february: number;
const feb: number;
const march: number;
const mar: number;
const april: number;
const apr: number;
const may: number;
const june: number;
const jun: number;
const july: number;
const jul: number;
const august: number;
const aug: number;
const september: number;
const sep: number;
const october: number;
const oct: number;
const november: number;
const nov: number;
const december: number;
const dec: number;
}
export namespace dayname {
const sunday: number;
const sun: number;
const monday: number;
const mon: number;
const tuesday: number;
const tue: number;
const wednesday: number;
const wed: number;
const thursday: number;
const thu: number;
const friday: number;
const fri: number;
const saturday: number;
const sat: number;
}
export const digit: {};
export { timezoneNames as zone, twoDigitYears as year };
}
declare module "src/data/templates" {
export namespace latn {
const MONTHNAME: string;
const DAYNAME: string;
const ZONE: string;
const MERIDIEM: string;
const ORDINAL: string;
const YEAR: string;
const MONTH: string;
const MONTH2: string;
const DAY: string;
const DAY2: string;
const OFFSET: string;
const H24: string;
const H12: string;
const MIN: string;
const SEC: string;
const MS: string;
const SPACE: string;
}
export namespace other {
const YEAR_1: string;
export { YEAR_1 as YEAR };
const MONTH_1: string;
export { MONTH_1 as MONTH };
const MONTH2_1: string;
export { MONTH2_1 as MONTH2 };
const DAY_1: string;
export { DAY_1 as DAY };
const DAY2_1: string;
export { DAY2_1 as DAY2 };
const OFFSET_1: string;
export { OFFSET_1 as OFFSET };
const H24_1: string;
export { H24_1 as H24 };
const H12_1: string;
export { H12_1 as H12 };
const MIN_1: string;
export { MIN_1 as MIN };
const SEC_1: string;
export { SEC_1 as SEC };
const MS_1: string;
export { MS_1 as MS };
}
}
declare module "src/data/numberingSystems" {
export const chineseGroup: "[0123456789〇一二三四五六七八九\\d]";
export const defaultLookup: {
0: number;
1: number;
2: number;
3: number;
4: number;
5: number;
6: number;
7: number;
8: number;
9: number;
'\uFF10': number;
'\uFF11': number;
'\uFF12': number;
'\uFF13': number;
'\uFF14': number;
'\uFF15': number;
'\uFF16': number;
'\uFF17': number;
'\uFF18': number;
'\uFF19': number;
〇: number;
一: number;
二: number;
三: number;
四: number;
五: number;
六: number;
七: number;
八: number;
九: number;
};
export namespace startCodes {
const arab: number;
const arabext: number;
const bali: number;
const beng: number;
const deva: number;
const fullwide: number;
const gujr: number;
const khmr: number;
const knda: number;
const laoo: number;
const limb: number;
const mlym: number;
const mong: number;
const mymr: number;
const orya: number;
const tamldec: number;
const telu: number;
const thai: number;
const tibt: number;
}
export function buildDigits(nsName: any): any;
}
declare module "src/data/units" {
export = units;
const units: string[];
}
declare module "src/LocaleHelper/LocaleHelper" {
export = LocaleHelper;
class LocaleHelper {
/**
* Get a singleton instance with the given locale
* @param {String} locale such as en, en-US, es, fr-FR, etc.
* @returns {LocaleHelper}
*/
static factory(locale?: string): LocaleHelper;
/**
* Create a new instance with the given locale
* @param {String} locale such as en, en-US, es, fr-FR, etc.
*/
constructor(locale?: string);
/**
* The locale string
* @type {String}
*/
locale: string;
/**
* Lookups for zone, year, meridiem, month, dayname, digit
* @type {Object} lookups
*/
lookups: any;
/**
* Template variables including MONTHNAME, MONTH, ZONE, etc.
* @type {Object} vars
*/
vars: any;
/**
* The numbering system to use (latn=standard arabic digits)
* @type {String} numberingSystem
*/
numberingSystem: string;
/**
* Cast a string to an integer, minding numbering system
* @param {String|Number} digitString Such as "2020" or "二〇二〇"
* @returns {Number}
*/
toInt(digitString: string | number): number;
/**
* Build lookups for digits, month names, day names, and meridiems based on the locale
*/
build(): void;
/**
* Build lookups for digits
*/
buildNumbers(): void;
/**
* Build lookup for month names
*/
buildMonthNames(): void;
/**
* Build lookup for day name
*/
buildDaynames(): void;
/**
* Build lookup for meridiems (e.g. AM/PM)
*/
buildMeridiems(): void;
/**
* Given a list of unit names and matches, build result object
* @param {Array} units Unit names such as "year", "month" and "millisecond"
* @param {Array} matches The values matched by a Format's RegExp
* @returns {Object}
*/
getObject(units: any[], matches: any[]): any;
/**
* Take a response object and cast each unit to Number
* @param {Object} object An object with one or more units
* @returns {Object} An object with same units but Numeric
*/
castObject(object: any): any;
/**
* Convert an offset string to Numeric minutes (e.g. "-0500", "+5", "+03:30")
* @param {String} offsetString
* @returns {Number}
*/
offsetToMinutes(offsetString: string): number;
/**
* Compile template into a RegExp and return it
* @param {String} template The template string
* @returns {RegExp}
*/
compile(template: string): RegExp;
}
}
declare module "src/Format/Format" {
export = Format;
/**
* Represents a parsable date format
*/
class Format {
/**
* Given a definition, create a parsable format
* @param {Object} definition The format definition
* @property {String} template A template for RegExp that can handle multiple languages
* @property {RegExp} matcher An actual RegExp to match against
* @property {Array} units If the template or RegExp match exact units, you can define the units
* @property {Function} handler A flexible alternative to units; must return an object
* @property {Array} locales A list of locales that this format should be restricted to
*/
constructor({ template, matcher, units, handler, locales, }: any);
/**
* @type {String} template A template for RegExp that can handle multiple languages
*/
template: string;
/**
* @type {Array} units If the template or RegExp match exact units, you can define the units
*/
units: any[];
/**
* @type {RegExp} matcher An actual RegExp to match against
*/
matcher: RegExp;
/**
* @type {Function} handler A flexible alternative to units; must return an object
*/
handler: Function;
/**
* @type {String[]} locales A list of locales that this format should be restricted to
*/
locales: string[];
/**
* A cache of RegExp indexed by locale name
* @type {Object}
*/
regexByLocale: any;
/**
* Build the RegExp from the template for a given locale
* @param {String} locale The language locale such as en-US, pt-BR, zh, es, etc.
* @returns {RegExp} A RegExp that matches when this format is recognized
*/
getRegExp(locale?: string): RegExp;
/**
* Run this format's RegExp against the given string
* @param {String} string The date string
* @param {String} locale The language locale such as en-US, pt-BR, zh, es, etc.
* @returns {Array|null} Array of matches or null on non-match
*/
getMatches(string: string, locale?: string): any[] | null;
/**
* Given matches against this RegExp, convert to object
* @param {String[]} matches An array of matched parts
* @param {String} locale The language locale such as en-US, pt-BR, zh, es, etc.
* @returns {Object} Object which may contain year, month, day, hour, minute, second, millisecond, offset, invalid
*/
toDateTime(matches: string[], locale?: string): any;
/**
* Attempt to parse a string in this format
* @param {String} string The date string
* @param {String} locale The language locale such as en-US, pt-BR, zh, es, etc.
* @returns {Object|null} Null if format can't handle this string, Object for result or error
*/
attempt(string: string, locale?: string): any | null;
/**
* Return the current date (used to support unit testing)
* @returns {Date}
*/
now(): Date;
}
}
declare module "src/fromString/fromString" {
export = fromString;
function fromString(parser: any, defaultLocale: any): (string: any, locale?: any) => any;
}
declare module "src/fromAny/fromAny" {
export = fromAny;
function fromAny(fromString: any): (any: any, locale: any) => any;
}
declare module "src/Parser/Parser" {
export = Parser;
class Parser {
formats: any[];
/**
* Register a format object representing a parseable date format
* @param {Format} format The Format to add
* @returns {Parser}
* @chainable
*/
addFormat(format: Format): Parser;
/**
* Register multiple formats
* @param {Format[]} formats The array of Formats to add
* @returns {Parser}
* @chainable
*/
addFormats(formats: Format[]): Parser;
/**
* Unregister a format
* @param {Format} format The Format to remove
* @returns {Boolean} true if format was found and removed, false if it wasn't registered
*/
removeFormat(format: Format): boolean;
/**
* Attempt to parse a date string
* @param {String} date A parseable date string
* @param {String} locale The name of the locale
* @returns {Object}
*/
attempt(date: string, locale?: string): any;
/**
* Export this parser as a single function that takes a string
* @param {String} locale The default locale it should use
* @returns {Function}
*/
exportAsFunction(locale?: string): Function;
/**
* Export this parser as a single function that takes a string or Date
* @param {String} locale The default locale it should use
* @returns {Function}
*/
exportAsFunctionAny(locale?: string): Function;
}
import Format = require("src/Format/Format");
}
declare module "src/formats/atSeconds/atSeconds" {
export = atSeconds;
const atSeconds: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/microsoftJson/microsoftJson" {
export = microsoftJson;
const microsoftJson: Format;
import Format = require("src/Format/Format");
}
declare module "src/data/unitShortcuts" {
export const y: string;
export const M: string;
export const d: string;
export const w: string;
export const h: string;
export const m: string;
export const s: string;
export const ms: string;
}
declare module "src/formats/ago/ago" {
export = ago;
const ago: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/chinese/chinese" {
export = chinese;
const chinese: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/dayMonth/dayMonth" {
export = dayMonth;
const dayMonth: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/dayMonthname/dayMonthname" {
export = dayMonthname;
const dayMonthname: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/dayMonthnameYear/dayMonthnameYear" {
export = dayMonthnameYear;
const dayMonthnameYear: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/dayMonthYear/dayMonthYear" {
export = dayMonthYear;
const dayMonthYear: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/monthDay/monthDay" {
export = monthDay;
const monthDay: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/monthDayYear/monthDayYear" {
export = monthDayYear;
const monthDayYear: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/monthnameDay/monthnameDay" {
export = monthnameDay;
const monthnameDay: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/monthnameDayYear/monthnameDayYear" {
export = monthnameDayYear;
const monthnameDayYear: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/time12Hours/time12Hours" {
export = time12Hours;
const time12Hours: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/time24Hours/time24Hours" {
export = time24Hours;
const time24Hours: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/today/today" {
export = today;
const today: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/twitter/twitter" {
export = twitter;
const twitter: Format;
import Format = require("src/Format/Format");
}
declare module "src/formats/yearMonthDay/yearMonthDay" {
export = yearMonthDay;
const yearMonthDay: Format;
import Format = require("src/Format/Format");
}
declare module "any-date-parser" {
export = parser;
const parser: Parser;
import Parser = require("src/Parser/Parser");
}