@breadstone/mosaik-elements-foundation 0.0.264 → 0.0.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Controls/Components/Inputs/Calendar/CalendarElement.d.ts +4 -12
- package/Controls/Components/Inputs/Calendar/CalendarElement.d.ts.map +1 -1
- package/Controls/Components/Inputs/Calendar/CalendarElement.js +3 -24
- package/Controls/Components/Inputs/Calendar/CalendarElement.js.map +1 -1
- package/Controls/Components/Inputs/Calendar/CalendarElementTemplate.d.ts.map +1 -1
- package/Controls/Components/Inputs/Calendar/CalendarElementTemplate.js +22 -23
- package/Controls/Components/Inputs/Calendar/CalendarElementTemplate.js.map +1 -1
- package/Controls/Components/Inputs/Calendar/ICalendarElementProps.d.ts +2 -5
- package/Controls/Components/Inputs/Calendar/ICalendarElementProps.d.ts.map +1 -1
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Cosmopolitan.d.ts.map +1 -1
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Cosmopolitan.js +15 -7
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Cosmopolitan.js.map +1 -1
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Joy.d.ts.map +1 -1
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Joy.js +15 -7
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Joy.js.map +1 -1
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Memphis.d.ts.map +1 -1
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Memphis.js +15 -7
- package/Controls/Components/Inputs/Calendar/Themes/CalendarElement.Memphis.js.map +1 -1
- package/Controls/Components/Inputs/DateBox/DateBoxElement.d.ts.map +1 -1
- package/Controls/Components/Inputs/DateBox/DateBoxElement.js +7 -2
- package/Controls/Components/Inputs/DateBox/DateBoxElement.js.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/DateTimeBoxElement.d.ts +90 -1
- package/Controls/Components/Inputs/DateTimeBox/DateTimeBoxElement.d.ts.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/DateTimeBoxElement.js +186 -9
- package/Controls/Components/Inputs/DateTimeBox/DateTimeBoxElement.js.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/DateTimeBoxElementTemplate.d.ts.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/DateTimeBoxElementTemplate.js +72 -37
- package/Controls/Components/Inputs/DateTimeBox/DateTimeBoxElementTemplate.js.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Cosmopolitan.d.ts.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Cosmopolitan.js +35 -0
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Cosmopolitan.js.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Joy.d.ts.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Joy.js +35 -0
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Joy.js.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Memphis.d.ts.map +1 -1
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Memphis.js +35 -0
- package/Controls/Components/Inputs/DateTimeBox/Themes/DateTimeBoxElement.Memphis.js.map +1 -1
- package/Controls/Components/Inputs/ToggleSwitch/Themes/ToggleSwitchElement.Joy.d.ts.map +1 -1
- package/Controls/Components/Inputs/ToggleSwitch/Themes/ToggleSwitchElement.Joy.js +8 -7
- package/Controls/Components/Inputs/ToggleSwitch/Themes/ToggleSwitchElement.Joy.js.map +1 -1
- package/Controls/Components/Overlays/Drawer/DrawerElement.d.ts +80 -0
- package/Controls/Components/Overlays/Drawer/DrawerElement.d.ts.map +1 -1
- package/Controls/Components/Overlays/Drawer/DrawerElement.js +147 -1
- package/Controls/Components/Overlays/Drawer/DrawerElement.js.map +1 -1
- package/Controls/Components/Overlays/Drawer/DrawerElementTemplate.d.ts.map +1 -1
- package/Controls/Components/Overlays/Drawer/DrawerElementTemplate.js +5 -37
- package/Controls/Components/Overlays/Drawer/DrawerElementTemplate.js.map +1 -1
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Cosmopolitan.d.ts.map +1 -1
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Cosmopolitan.js +3 -2
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Cosmopolitan.js.map +1 -1
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Joy.d.ts.map +1 -1
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Joy.js +10 -2
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Joy.js.map +1 -1
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Memphis.d.ts.map +1 -1
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Memphis.js +3 -2
- package/Controls/Components/Overlays/Drawer/Themes/DrawerElement.Memphis.js.map +1 -1
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerElementProps.d.ts +20 -0
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerElementProps.d.ts.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerElementProps.js +3 -0
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerElementProps.js.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerItem.d.ts +16 -0
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerItem.d.ts.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerItem.js +2 -0
- package/Controls/Components/Primitives/WheelPicker/IWheelPickerItem.js.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Cosmopolitan.d.ts +6 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Cosmopolitan.d.ts.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Cosmopolitan.js +179 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Cosmopolitan.js.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Joy.d.ts +6 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Joy.d.ts.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Joy.js +179 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Joy.js.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Memphis.d.ts +6 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Memphis.d.ts.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Memphis.js +179 -0
- package/Controls/Components/Primitives/WheelPicker/Themes/WheelPickerElement.Memphis.js.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElement.d.ts +140 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElement.d.ts.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElement.js +213 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElement.js.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElementTemplate.d.ts +9 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElementTemplate.d.ts.map +1 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElementTemplate.js +29 -0
- package/Controls/Components/Primitives/WheelPicker/WheelPickerElementTemplate.js.map +1 -0
- package/Controls/Components/Shell/Themes/AppElement.Cosmopolitan.d.ts.map +1 -1
- package/Controls/Components/Shell/Themes/AppElement.Cosmopolitan.js +1 -0
- package/Controls/Components/Shell/Themes/AppElement.Cosmopolitan.js.map +1 -1
- package/Controls/Components/Shell/Themes/AppElement.Joy.d.ts.map +1 -1
- package/Controls/Components/Shell/Themes/AppElement.Joy.js +1 -0
- package/Controls/Components/Shell/Themes/AppElement.Joy.js.map +1 -1
- package/Controls/Components/Shell/Themes/AppElement.Memphis.d.ts.map +1 -1
- package/Controls/Components/Shell/Themes/AppElement.Memphis.js +1 -0
- package/Controls/Components/Shell/Themes/AppElement.Memphis.js.map +1 -1
- package/Controls/events/WheelPickerEvents.d.ts +24 -0
- package/Controls/events/WheelPickerEvents.d.ts.map +1 -0
- package/Controls/events/WheelPickerEvents.js +3 -0
- package/Controls/events/WheelPickerEvents.js.map +1 -0
- package/Controls/events/index.d.ts +1 -0
- package/Controls/events/index.d.ts.map +1 -1
- package/Index.d.ts +3 -0
- package/Index.d.ts.map +1 -1
- package/Index.js +1 -0
- package/Index.js.map +1 -1
- package/Intl/Formatters/DateTimeFormatter.d.ts +16 -0
- package/Intl/Formatters/DateTimeFormatter.d.ts.map +1 -1
- package/Intl/Formatters/DateTimeFormatter.js +62 -9
- package/Intl/Formatters/DateTimeFormatter.js.map +1 -1
- package/Intl/Formatters/TimeFormatter.d.ts +6 -4
- package/Intl/Formatters/TimeFormatter.d.ts.map +1 -1
- package/Intl/Formatters/TimeFormatter.js +6 -4
- package/Intl/Formatters/TimeFormatter.js.map +1 -1
- package/Intl/parsers/DateParser.d.ts +63 -0
- package/Intl/parsers/DateParser.d.ts.map +1 -0
- package/Intl/parsers/DateParser.js +139 -0
- package/Intl/parsers/DateParser.js.map +1 -0
- package/Intl/parsers/DateTimeParser.d.ts +85 -0
- package/Intl/parsers/DateTimeParser.d.ts.map +1 -0
- package/Intl/parsers/DateTimeParser.js +223 -0
- package/Intl/parsers/DateTimeParser.js.map +1 -0
- package/Routing/PathToRegexp.d.ts +1 -1
- package/custom-elements.json +770 -22
- package/package.json +3 -3
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility class for parsing date strings using format strings.
|
|
3
|
+
*
|
|
4
|
+
* Supported date format specifiers:
|
|
5
|
+
* - `d` : Day of the month (1-31) without leading zero.
|
|
6
|
+
* - `dd` : Day of the month (01-31) with leading zero.
|
|
7
|
+
* - `M` : Month (1-12) without leading zero.
|
|
8
|
+
* - `MM` : Month (01-12) with leading zero.
|
|
9
|
+
* - `y` : Year as the last two digits without leading zero.
|
|
10
|
+
* - `yy` : Year as the last two digits with leading zero.
|
|
11
|
+
* - `yyyy`: Year as a four-digit number.
|
|
12
|
+
* - `-` : Separator (hyphen).
|
|
13
|
+
* - `/` : Separator (slash).
|
|
14
|
+
* - `.` : Separator (dot).
|
|
15
|
+
* - ` ` : Separator (space).
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export class DateParser {
|
|
20
|
+
// #region Fields
|
|
21
|
+
static _segmentRegex = /d{1,2}|y{1,4}|M{1,2}|[-/. ]+/g;
|
|
22
|
+
// #endregion
|
|
23
|
+
// #region Methods
|
|
24
|
+
/**
|
|
25
|
+
* Attempts to parse a date string using the provided format.
|
|
26
|
+
* Returns `null` if parsing fails or produces an invalid date.
|
|
27
|
+
*
|
|
28
|
+
* @param value The date string to parse.
|
|
29
|
+
* @param format The expected format of the date string.
|
|
30
|
+
* @param locale The locale (reserved for future use).
|
|
31
|
+
* @returns The parsed Date or null.
|
|
32
|
+
*/
|
|
33
|
+
static tryParse(value, format, locale) {
|
|
34
|
+
try {
|
|
35
|
+
const date = this.parse(value, format, locale);
|
|
36
|
+
if (!this.isValidDate(date)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return date;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parses a date string according to the given format string.
|
|
47
|
+
*
|
|
48
|
+
* @param value The date string to parse.
|
|
49
|
+
* @param format The format string describing the layout.
|
|
50
|
+
* @param locale The locale (reserved for future use).
|
|
51
|
+
* @returns The parsed Date.
|
|
52
|
+
* @throws Error if the format or value cannot be parsed.
|
|
53
|
+
*/
|
|
54
|
+
static parse(value, format, locale) {
|
|
55
|
+
const segments = format.match(this._segmentRegex);
|
|
56
|
+
if (!segments) {
|
|
57
|
+
throw new Error(`Unable to parse format string: "${format}".`);
|
|
58
|
+
}
|
|
59
|
+
let position = 0;
|
|
60
|
+
let day = 1;
|
|
61
|
+
let month = 0;
|
|
62
|
+
let year = 0;
|
|
63
|
+
for (const segment of segments) {
|
|
64
|
+
if ((/[-/. ]+/).test(segment)) {
|
|
65
|
+
// Skip separator characters in the value
|
|
66
|
+
position += segment.length;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const extracted = this.extractNumericValue(value, position, segment);
|
|
70
|
+
position += extracted.length;
|
|
71
|
+
switch (segment) {
|
|
72
|
+
case 'd':
|
|
73
|
+
case 'dd':
|
|
74
|
+
day = extracted.value;
|
|
75
|
+
break;
|
|
76
|
+
case 'M':
|
|
77
|
+
case 'MM':
|
|
78
|
+
month = extracted.value - 1; // Months are zero-based
|
|
79
|
+
break;
|
|
80
|
+
case 'y':
|
|
81
|
+
case 'yy':
|
|
82
|
+
year = extracted.value < 100 ? 2000 + extracted.value : extracted.value;
|
|
83
|
+
break;
|
|
84
|
+
case 'yyy':
|
|
85
|
+
case 'yyyy':
|
|
86
|
+
year = extracted.value;
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
throw new Error(`Unknown date format segment: "${segment}".`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const date = new Date(year, month, day);
|
|
93
|
+
// Validate that the constructed date matches the parsed values
|
|
94
|
+
if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
|
|
95
|
+
throw new Error(`Invalid date values: day=${day}, month=${month + 1}, year=${year}.`);
|
|
96
|
+
}
|
|
97
|
+
return date;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Extracts a numeric value from the input string at the given position.
|
|
101
|
+
* The number of digits consumed is determined by the format segment:
|
|
102
|
+
* - `yyyy` / `yyy`: up to 4 digits (min 3 or 4 depending on specifier length).
|
|
103
|
+
* - `dd` / `MM` / `yy`: exactly 2 digits.
|
|
104
|
+
* - `d` / `M` / `y`: 1 to 2 digits (greedy).
|
|
105
|
+
*
|
|
106
|
+
* @param value - The full input string being parsed.
|
|
107
|
+
* @param position - The current character index in `value`.
|
|
108
|
+
* @param segment - The format segment (e.g., `"dd"`, `"M"`, `"yyyy"`).
|
|
109
|
+
* @returns An object containing the parsed numeric `value` and the `length` of characters consumed.
|
|
110
|
+
* @throws Error if fewer digits are found than the segment requires.
|
|
111
|
+
*/
|
|
112
|
+
static extractNumericValue(value, position, segment) {
|
|
113
|
+
const maxLength = segment === 'yyyy' || segment === 'yyy' ? 4 : segment.length === 2 ? 2 : 2;
|
|
114
|
+
const minLength = segment.length === 1 ? 1 : segment.length;
|
|
115
|
+
let end = position;
|
|
116
|
+
while (end < value.length && end - position < maxLength && (/\d/).test(value[end])) {
|
|
117
|
+
end++;
|
|
118
|
+
}
|
|
119
|
+
const extracted = value.substring(position, end);
|
|
120
|
+
if (extracted.length < minLength) {
|
|
121
|
+
throw new Error(`Expected at least ${minLength} digit(s) for segment "${segment}" at position ${position}, got "${extracted}".`);
|
|
122
|
+
}
|
|
123
|
+
const numericValue = parseInt(extracted, 10);
|
|
124
|
+
if (isNaN(numericValue)) {
|
|
125
|
+
throw new Error(`Unable to parse numeric value for segment "${segment}" at position ${position}.`);
|
|
126
|
+
}
|
|
127
|
+
return { value: numericValue, length: extracted.length };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Checks whether the given Date object represents a valid point in time.
|
|
131
|
+
*
|
|
132
|
+
* @param date - The Date object to validate.
|
|
133
|
+
* @returns `true` if the date is valid (not `NaN`), otherwise `false`.
|
|
134
|
+
*/
|
|
135
|
+
static isValidDate(date) {
|
|
136
|
+
return !isNaN(date.getTime());
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=DateParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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CAAC;IAClC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility class for parsing date-time strings using format strings.
|
|
3
|
+
*
|
|
4
|
+
* Supported format specifiers:
|
|
5
|
+
* - `d` : Day of the month (1-31) without leading zero.
|
|
6
|
+
* - `dd` : Day of the month (01-31) with leading zero.
|
|
7
|
+
* - `M` : Month (1-12) without leading zero.
|
|
8
|
+
* - `MM` : Month (01-12) with leading zero.
|
|
9
|
+
* - `h` : Hour (1-12) in 12-hour format without leading zero.
|
|
10
|
+
* - `hh` : Hour (01-12) in 12-hour format with leading zero.
|
|
11
|
+
* - `H` : Hour (0-23) in 24-hour format without leading zero.
|
|
12
|
+
* - `HH` : Hour (00-23) in 24-hour format with leading zero.
|
|
13
|
+
* - `m` : Minute (0-59) without leading zero.
|
|
14
|
+
* - `mm` : Minute (00-59) with leading zero.
|
|
15
|
+
* - `s` : Second (0-59) without leading zero.
|
|
16
|
+
* - `ss` : Second (00-59) with leading zero.
|
|
17
|
+
* - `tt` : AM/PM designator.
|
|
18
|
+
* - `y` : Year as the last two digits without leading zero.
|
|
19
|
+
* - `yy` : Year as the last two digits with leading zero.
|
|
20
|
+
* - `yyyy`: Year as a four-digit number.
|
|
21
|
+
* - `:` : Time separator.
|
|
22
|
+
* - `/` : Date separator.
|
|
23
|
+
* - `-` : Separator (hyphen).
|
|
24
|
+
* - `.` : Separator (dot).
|
|
25
|
+
* - ` ` : Separator (space).
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare class DateTimeParser {
|
|
30
|
+
private static readonly _segmentRegex;
|
|
31
|
+
/**
|
|
32
|
+
* Attempts to parse a date-time string using the provided format.
|
|
33
|
+
* Returns `null` if parsing fails or produces an invalid date.
|
|
34
|
+
*
|
|
35
|
+
* @param value The date-time string to parse.
|
|
36
|
+
* @param format The expected format of the date-time string.
|
|
37
|
+
* @param locale The locale (reserved for future use).
|
|
38
|
+
* @returns The parsed Date or null.
|
|
39
|
+
*/
|
|
40
|
+
static tryParse(value: string, format: string, locale: string): Date | null;
|
|
41
|
+
/**
|
|
42
|
+
* Parses a date-time string according to the given format string.
|
|
43
|
+
*
|
|
44
|
+
* @param value The date-time string to parse.
|
|
45
|
+
* @param format The format string describing the layout.
|
|
46
|
+
* @param locale The locale (reserved for future use).
|
|
47
|
+
* @returns The parsed Date.
|
|
48
|
+
* @throws Error if the format or value cannot be parsed.
|
|
49
|
+
*/
|
|
50
|
+
static parse(value: string, format: string, locale: string): Date;
|
|
51
|
+
/**
|
|
52
|
+
* Extracts a numeric value from the input string at the given position.
|
|
53
|
+
* The number of digits consumed is determined by the format segment:
|
|
54
|
+
* - `yyyy` / `yyy`: up to 4 digits.
|
|
55
|
+
* - All other segments (`dd`, `MM`, `HH`, `hh`, `mm`, `ss`, etc.): up to 2 digits.
|
|
56
|
+
* Single-character specifiers (`d`, `M`, `H`, `h`, `m`, `s`) require at least 1 digit;
|
|
57
|
+
* two-character specifiers require exactly 2.
|
|
58
|
+
*
|
|
59
|
+
* @param value - The full input string being parsed.
|
|
60
|
+
* @param position - The current character index in `value`.
|
|
61
|
+
* @param segment - The format segment (e.g., `"HH"`, `"m"`, `"yyyy"`).
|
|
62
|
+
* @returns An object containing the parsed numeric `value` and the `length` of characters consumed.
|
|
63
|
+
* @throws Error if fewer digits are found than the segment requires.
|
|
64
|
+
*/
|
|
65
|
+
private static extractNumericValue;
|
|
66
|
+
/**
|
|
67
|
+
* Extracts the AM/PM designator from the input string at the given position.
|
|
68
|
+
* Recognized patterns (case-insensitive): `"AM"`, `"PM"`, `"A.M."`, `"P.M."`,
|
|
69
|
+
* and single characters `"A"` / `"P"` (for the `t` specifier).
|
|
70
|
+
*
|
|
71
|
+
* @param value - The full input string being parsed.
|
|
72
|
+
* @param position - The current character index in `value`.
|
|
73
|
+
* @returns An object with `isPm` (true for PM) and `length` of characters consumed.
|
|
74
|
+
* @throws Error if no valid AM/PM designator is found at the position.
|
|
75
|
+
*/
|
|
76
|
+
private static extractAmPm;
|
|
77
|
+
/**
|
|
78
|
+
* Checks whether the given Date object represents a valid point in time.
|
|
79
|
+
*
|
|
80
|
+
* @param date - The Date object to validate.
|
|
81
|
+
* @returns `true` if the date is valid (not `NaN`), otherwise `false`.
|
|
82
|
+
*/
|
|
83
|
+
private static isValidDate;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=DateTimeParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimeParser.d.ts","sourceRoot":"","sources":["../../../src/Intl/parsers/DateTimeParser.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,cAAc;IAIvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAuE;IAM5G;;;;;;;;OAQG;WACW,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAalF;;;;;;;;OAQG;WACW,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAoGxE;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAsBlC;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAyB1B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAM7B"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility class for parsing date-time strings using format strings.
|
|
3
|
+
*
|
|
4
|
+
* Supported format specifiers:
|
|
5
|
+
* - `d` : Day of the month (1-31) without leading zero.
|
|
6
|
+
* - `dd` : Day of the month (01-31) with leading zero.
|
|
7
|
+
* - `M` : Month (1-12) without leading zero.
|
|
8
|
+
* - `MM` : Month (01-12) with leading zero.
|
|
9
|
+
* - `h` : Hour (1-12) in 12-hour format without leading zero.
|
|
10
|
+
* - `hh` : Hour (01-12) in 12-hour format with leading zero.
|
|
11
|
+
* - `H` : Hour (0-23) in 24-hour format without leading zero.
|
|
12
|
+
* - `HH` : Hour (00-23) in 24-hour format with leading zero.
|
|
13
|
+
* - `m` : Minute (0-59) without leading zero.
|
|
14
|
+
* - `mm` : Minute (00-59) with leading zero.
|
|
15
|
+
* - `s` : Second (0-59) without leading zero.
|
|
16
|
+
* - `ss` : Second (00-59) with leading zero.
|
|
17
|
+
* - `tt` : AM/PM designator.
|
|
18
|
+
* - `y` : Year as the last two digits without leading zero.
|
|
19
|
+
* - `yy` : Year as the last two digits with leading zero.
|
|
20
|
+
* - `yyyy`: Year as a four-digit number.
|
|
21
|
+
* - `:` : Time separator.
|
|
22
|
+
* - `/` : Date separator.
|
|
23
|
+
* - `-` : Separator (hyphen).
|
|
24
|
+
* - `.` : Separator (dot).
|
|
25
|
+
* - ` ` : Separator (space).
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export class DateTimeParser {
|
|
30
|
+
// #region Fields
|
|
31
|
+
static _segmentRegex = /d{1,2}|y{1,4}|M{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|t{1,2}|[-:/. ]+/g;
|
|
32
|
+
// #endregion
|
|
33
|
+
// #region Methods
|
|
34
|
+
/**
|
|
35
|
+
* Attempts to parse a date-time string using the provided format.
|
|
36
|
+
* Returns `null` if parsing fails or produces an invalid date.
|
|
37
|
+
*
|
|
38
|
+
* @param value The date-time string to parse.
|
|
39
|
+
* @param format The expected format of the date-time string.
|
|
40
|
+
* @param locale The locale (reserved for future use).
|
|
41
|
+
* @returns The parsed Date or null.
|
|
42
|
+
*/
|
|
43
|
+
static tryParse(value, format, locale) {
|
|
44
|
+
try {
|
|
45
|
+
const date = this.parse(value, format, locale);
|
|
46
|
+
if (!this.isValidDate(date)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return date;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parses a date-time string according to the given format string.
|
|
57
|
+
*
|
|
58
|
+
* @param value The date-time string to parse.
|
|
59
|
+
* @param format The format string describing the layout.
|
|
60
|
+
* @param locale The locale (reserved for future use).
|
|
61
|
+
* @returns The parsed Date.
|
|
62
|
+
* @throws Error if the format or value cannot be parsed.
|
|
63
|
+
*/
|
|
64
|
+
static parse(value, format, locale) {
|
|
65
|
+
const segments = format.match(this._segmentRegex);
|
|
66
|
+
if (!segments) {
|
|
67
|
+
throw new Error(`Unable to parse format string: "${format}".`);
|
|
68
|
+
}
|
|
69
|
+
let position = 0;
|
|
70
|
+
let day = 1;
|
|
71
|
+
let month = 0;
|
|
72
|
+
let year = 0;
|
|
73
|
+
let hours = 0;
|
|
74
|
+
let minutes = 0;
|
|
75
|
+
let seconds = 0;
|
|
76
|
+
let isPm = null;
|
|
77
|
+
let is12Hour = false;
|
|
78
|
+
for (const segment of segments) {
|
|
79
|
+
if ((/[-:/. ]+/).test(segment)) {
|
|
80
|
+
position += segment.length;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (segment === 't' || segment === 'tt') {
|
|
84
|
+
const amPm = this.extractAmPm(value, position);
|
|
85
|
+
isPm = amPm.isPm;
|
|
86
|
+
position += amPm.length;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const extracted = this.extractNumericValue(value, position, segment);
|
|
90
|
+
position += extracted.length;
|
|
91
|
+
switch (segment) {
|
|
92
|
+
case 'd':
|
|
93
|
+
case 'dd':
|
|
94
|
+
day = extracted.value;
|
|
95
|
+
break;
|
|
96
|
+
case 'M':
|
|
97
|
+
case 'MM':
|
|
98
|
+
month = extracted.value - 1;
|
|
99
|
+
break;
|
|
100
|
+
case 'y':
|
|
101
|
+
case 'yy':
|
|
102
|
+
year = extracted.value < 100 ? 2000 + extracted.value : extracted.value;
|
|
103
|
+
break;
|
|
104
|
+
case 'yyy':
|
|
105
|
+
case 'yyyy':
|
|
106
|
+
year = extracted.value;
|
|
107
|
+
break;
|
|
108
|
+
case 'h':
|
|
109
|
+
case 'hh':
|
|
110
|
+
hours = extracted.value;
|
|
111
|
+
is12Hour = true;
|
|
112
|
+
break;
|
|
113
|
+
case 'H':
|
|
114
|
+
case 'HH':
|
|
115
|
+
hours = extracted.value;
|
|
116
|
+
break;
|
|
117
|
+
case 'm':
|
|
118
|
+
case 'mm':
|
|
119
|
+
minutes = extracted.value;
|
|
120
|
+
break;
|
|
121
|
+
case 's':
|
|
122
|
+
case 'ss':
|
|
123
|
+
seconds = extracted.value;
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`Unknown datetime format segment: "${segment}".`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Validate 12-hour range (must be 1-12)
|
|
130
|
+
if (is12Hour && (hours < 1 || hours > 12)) {
|
|
131
|
+
throw new Error(`Invalid 12-hour value: ${hours}. Must be between 1 and 12.`);
|
|
132
|
+
}
|
|
133
|
+
// Convert 12-hour to 24-hour
|
|
134
|
+
if (is12Hour && isPm !== null) {
|
|
135
|
+
if (isPm && hours !== 12) {
|
|
136
|
+
hours += 12;
|
|
137
|
+
}
|
|
138
|
+
else if (!isPm && hours === 12) {
|
|
139
|
+
hours = 0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const date = new Date(year, month, day, hours, minutes, seconds);
|
|
143
|
+
// Validate that the constructed date matches the parsed values
|
|
144
|
+
if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
|
|
145
|
+
throw new Error(`Invalid date values: day=${day}, month=${month + 1}, year=${year}.`);
|
|
146
|
+
}
|
|
147
|
+
// Validate that the constructed time matches the parsed values
|
|
148
|
+
if (date.getHours() !== hours || date.getMinutes() !== minutes || date.getSeconds() !== seconds) {
|
|
149
|
+
throw new Error(`Invalid time values: hours=${hours}, minutes=${minutes}, seconds=${seconds}.`);
|
|
150
|
+
}
|
|
151
|
+
return date;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Extracts a numeric value from the input string at the given position.
|
|
155
|
+
* The number of digits consumed is determined by the format segment:
|
|
156
|
+
* - `yyyy` / `yyy`: up to 4 digits.
|
|
157
|
+
* - All other segments (`dd`, `MM`, `HH`, `hh`, `mm`, `ss`, etc.): up to 2 digits.
|
|
158
|
+
* Single-character specifiers (`d`, `M`, `H`, `h`, `m`, `s`) require at least 1 digit;
|
|
159
|
+
* two-character specifiers require exactly 2.
|
|
160
|
+
*
|
|
161
|
+
* @param value - The full input string being parsed.
|
|
162
|
+
* @param position - The current character index in `value`.
|
|
163
|
+
* @param segment - The format segment (e.g., `"HH"`, `"m"`, `"yyyy"`).
|
|
164
|
+
* @returns An object containing the parsed numeric `value` and the `length` of characters consumed.
|
|
165
|
+
* @throws Error if fewer digits are found than the segment requires.
|
|
166
|
+
*/
|
|
167
|
+
static extractNumericValue(value, position, segment) {
|
|
168
|
+
const maxLength = segment === 'yyyy' || segment === 'yyy' ? 4 : 2;
|
|
169
|
+
const minLength = segment.length === 1 ? 1 : segment.length;
|
|
170
|
+
let end = position;
|
|
171
|
+
while (end < value.length && end - position < maxLength && (/\d/).test(value[end])) {
|
|
172
|
+
end++;
|
|
173
|
+
}
|
|
174
|
+
const extracted = value.substring(position, end);
|
|
175
|
+
if (extracted.length < minLength) {
|
|
176
|
+
throw new Error(`Expected at least ${minLength} digit(s) for segment "${segment}" at position ${position}, got "${extracted}".`);
|
|
177
|
+
}
|
|
178
|
+
const numericValue = parseInt(extracted, 10);
|
|
179
|
+
if (isNaN(numericValue)) {
|
|
180
|
+
throw new Error(`Unable to parse numeric value for segment "${segment}" at position ${position}.`);
|
|
181
|
+
}
|
|
182
|
+
return { value: numericValue, length: extracted.length };
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Extracts the AM/PM designator from the input string at the given position.
|
|
186
|
+
* Recognized patterns (case-insensitive): `"AM"`, `"PM"`, `"A.M."`, `"P.M."`,
|
|
187
|
+
* and single characters `"A"` / `"P"` (for the `t` specifier).
|
|
188
|
+
*
|
|
189
|
+
* @param value - The full input string being parsed.
|
|
190
|
+
* @param position - The current character index in `value`.
|
|
191
|
+
* @returns An object with `isPm` (true for PM) and `length` of characters consumed.
|
|
192
|
+
* @throws Error if no valid AM/PM designator is found at the position.
|
|
193
|
+
*/
|
|
194
|
+
static extractAmPm(value, position) {
|
|
195
|
+
const remaining = value.substring(position).toUpperCase();
|
|
196
|
+
if (remaining.startsWith('PM') || remaining.startsWith('P.M.')) {
|
|
197
|
+
const length = remaining.startsWith('P.M.') ? 4 : 2;
|
|
198
|
+
return { isPm: true, length };
|
|
199
|
+
}
|
|
200
|
+
if (remaining.startsWith('AM') || remaining.startsWith('A.M.')) {
|
|
201
|
+
const length = remaining.startsWith('A.M.') ? 4 : 2;
|
|
202
|
+
return { isPm: false, length };
|
|
203
|
+
}
|
|
204
|
+
// Single character: 't' specifier
|
|
205
|
+
if (remaining.startsWith('P')) {
|
|
206
|
+
return { isPm: true, length: 1 };
|
|
207
|
+
}
|
|
208
|
+
if (remaining.startsWith('A')) {
|
|
209
|
+
return { isPm: false, length: 1 };
|
|
210
|
+
}
|
|
211
|
+
throw new Error(`Unable to parse AM/PM designator at position ${position}.`);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Checks whether the given Date object represents a valid point in time.
|
|
215
|
+
*
|
|
216
|
+
* @param date - The Date object to validate.
|
|
217
|
+
* @returns `true` if the date is valid (not `NaN`), otherwise `false`.
|
|
218
|
+
*/
|
|
219
|
+
static isValidDate(date) {
|
|
220
|
+
return !isNaN(date.getTime());
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=DateTimeParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimeParser.js","sourceRoot":"","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C,gDAAgD,QAAQ,GAAG,CAAC,CAAC;IACjF,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,WAAW,CAAC,IAAU;QACjC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAClC,CAAC"}
|
|
@@ -91,7 +91,7 @@ export interface Options {
|
|
|
91
91
|
*/
|
|
92
92
|
encode?: (value: string) => string;
|
|
93
93
|
}
|
|
94
|
-
export declare function modifierToString(modifier: Modifier): "" | "*" | "
|
|
94
|
+
export declare function modifierToString(modifier: Modifier): "" | "*" | "?" | "+";
|
|
95
95
|
/**
|
|
96
96
|
* Expose a function for taking tokens and returning a RegExp.
|
|
97
97
|
*/
|