@pbkware/dot-net-date-number-formatting 0.2.0 → 0.3.0
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/README.md +5 -0
- package/dist/code/{datetime-formatter.js → date-time-formatter.js} +29 -16
- package/dist/code/date-time-formatter.js.map +1 -0
- package/dist/code/date-time-styles.js +157 -0
- package/dist/code/date-time-styles.js.map +1 -0
- package/dist/code/index.js +3 -3
- package/dist/code/index.js.map +1 -1
- package/dist/code/number-formatter.js +34 -26
- package/dist/code/number-formatter.js.map +1 -1
- package/dist/code/number-styles.js +204 -0
- package/dist/code/number-styles.js.map +1 -0
- package/dist/types/dot-net-date-number-formatting-untrimmed.d.ts +147 -86
- package/dist/types/public-api.d.ts +203 -61
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +4 -4
- package/src/code/{datetime-formatter.ts → date-time-formatter.ts} +29 -17
- package/src/code/date-time-styles.ts +200 -0
- package/src/code/index.ts +3 -3
- package/src/code/number-formatter.ts +46 -30
- package/src/code/number-styles.ts +265 -0
- package/dist/code/datetime-formatter.js.map +0 -1
- package/dist/code/datetime-style.js +0 -101
- package/dist/code/datetime-style.js.map +0 -1
- package/dist/code/number-style.js +0 -211
- package/dist/code/number-style.js.map +0 -1
- package/src/code/datetime-style.ts +0 -128
- package/src/code/number-style.ts +0 -247
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Individual style flags that control which number formats are allowed during parsing.
|
|
3
|
+
*
|
|
4
|
+
* These flags can be combined to create custom parsing behavior.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Combine individual flags
|
|
9
|
+
* formatter.styles = new Set([
|
|
10
|
+
* DotNetNumberStyleFlags.AllowLeadingSign,
|
|
11
|
+
* DotNetNumberStyleFlags.AllowDecimalPoint,
|
|
12
|
+
* DotNetNumberStyleFlags.AllowThousands
|
|
13
|
+
* ]);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
* @category Number Styles
|
|
18
|
+
*/
|
|
19
|
+
export const DotNetNumberStyleFlags = {
|
|
20
|
+
/** Allow leading whitespace characters. */
|
|
21
|
+
allowLeadingWhite: 1,
|
|
22
|
+
/** Allow trailing whitespace characters. */
|
|
23
|
+
allowTrailingWhite: 2,
|
|
24
|
+
/** Allow a leading plus (+) or minus (-) sign. */
|
|
25
|
+
allowLeadingSign: 4,
|
|
26
|
+
/** Allow a trailing plus (+) or minus (-) sign. */
|
|
27
|
+
allowTrailingSign: 8,
|
|
28
|
+
/** Allow parentheses to indicate negative numbers. */
|
|
29
|
+
allowParentheses: 16,
|
|
30
|
+
/** Allow decimal point in the number string. */
|
|
31
|
+
allowDecimalPoint: 32,
|
|
32
|
+
/** Allow thousands separator characters. */
|
|
33
|
+
allowThousands: 64,
|
|
34
|
+
/** Allow exponential notation (e.g., 1.23e+10). */
|
|
35
|
+
allowExponent: 128,
|
|
36
|
+
/** Allow currency symbol in the number string. */
|
|
37
|
+
allowCurrencySymbol: 256,
|
|
38
|
+
/** Parse the number as hexadecimal. */
|
|
39
|
+
allowHexSpecifier: 512,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Predefined number style combinations for common parsing scenarios.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // Use predefined style
|
|
47
|
+
* formatter.styles = DotNetNumberStyles.number;
|
|
48
|
+
* formatter.tryFromString('1,234.56'); // Parses successfully
|
|
49
|
+
*
|
|
50
|
+
* // Use currency style
|
|
51
|
+
* formatter.styles = DotNetNumberStyles.currency;
|
|
52
|
+
* formatter.tryFromString('$1,234.56'); // Parses successfully
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
* @category Number Styles
|
|
57
|
+
*/
|
|
58
|
+
export const DotNetNumberStyles = {
|
|
59
|
+
/** No styles - only basic digits allowed. */
|
|
60
|
+
none: 0,
|
|
61
|
+
allowLeadingWhite: DotNetNumberStyleFlags.allowLeadingWhite,
|
|
62
|
+
/** Allow trailing whitespace characters. */
|
|
63
|
+
allowTrailingWhite: DotNetNumberStyleFlags.allowTrailingWhite,
|
|
64
|
+
/** Allow a leading plus (+) or minus (-) sign. */
|
|
65
|
+
allowLeadingSign: DotNetNumberStyleFlags.allowLeadingSign,
|
|
66
|
+
/** Allow a trailing plus (+) or minus (-) sign. */
|
|
67
|
+
allowTrailingSign: DotNetNumberStyleFlags.allowTrailingSign,
|
|
68
|
+
/** Allow parentheses to indicate negative numbers. */
|
|
69
|
+
allowParentheses: DotNetNumberStyleFlags.allowParentheses,
|
|
70
|
+
/** Allow decimal point in the number string. */
|
|
71
|
+
allowDecimalPoint: DotNetNumberStyleFlags.allowDecimalPoint,
|
|
72
|
+
/** Allow thousands separator characters. */
|
|
73
|
+
allowThousands: DotNetNumberStyleFlags.allowThousands,
|
|
74
|
+
/** Allow exponential notation (e.g., 1.23e+10). */
|
|
75
|
+
allowExponent: DotNetNumberStyleFlags.allowExponent,
|
|
76
|
+
/** Allow currency symbol in the number string. */
|
|
77
|
+
allowCurrencySymbol: DotNetNumberStyleFlags.allowCurrencySymbol,
|
|
78
|
+
/** Parse the number as hexadecimal. */
|
|
79
|
+
allowHexSpecifier: DotNetNumberStyleFlags.allowHexSpecifier,
|
|
80
|
+
/**
|
|
81
|
+
* All styles allowed (except hex).
|
|
82
|
+
* Includes: AllowCurrencySymbol, AllowDecimalPoint, AllowExponent, AllowLeadingSign,
|
|
83
|
+
* AllowLeadingWhite, AllowParentheses, AllowThousands, AllowTrailingSign, AllowTrailingWhite.
|
|
84
|
+
*/
|
|
85
|
+
any: DotNetNumberStyleFlags.allowCurrencySymbol |
|
|
86
|
+
DotNetNumberStyleFlags.allowDecimalPoint |
|
|
87
|
+
DotNetNumberStyleFlags.allowExponent |
|
|
88
|
+
DotNetNumberStyleFlags.allowLeadingSign |
|
|
89
|
+
DotNetNumberStyleFlags.allowLeadingWhite |
|
|
90
|
+
DotNetNumberStyleFlags.allowParentheses |
|
|
91
|
+
DotNetNumberStyleFlags.allowThousands |
|
|
92
|
+
DotNetNumberStyleFlags.allowTrailingSign |
|
|
93
|
+
DotNetNumberStyleFlags.allowTrailingWhite,
|
|
94
|
+
/**
|
|
95
|
+
* Currency parsing style.
|
|
96
|
+
* Includes: AllowCurrencySymbol, AllowDecimalPoint, AllowLeadingSign, AllowLeadingWhite,
|
|
97
|
+
* AllowParentheses, AllowThousands, AllowTrailingSign, AllowTrailingWhite.
|
|
98
|
+
*/
|
|
99
|
+
currency: DotNetNumberStyleFlags.allowCurrencySymbol |
|
|
100
|
+
DotNetNumberStyleFlags.allowDecimalPoint |
|
|
101
|
+
DotNetNumberStyleFlags.allowLeadingSign |
|
|
102
|
+
DotNetNumberStyleFlags.allowLeadingWhite |
|
|
103
|
+
DotNetNumberStyleFlags.allowParentheses |
|
|
104
|
+
DotNetNumberStyleFlags.allowThousands |
|
|
105
|
+
DotNetNumberStyleFlags.allowTrailingSign |
|
|
106
|
+
DotNetNumberStyleFlags.allowTrailingWhite,
|
|
107
|
+
/**
|
|
108
|
+
* Floating-point parsing style.
|
|
109
|
+
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign,
|
|
110
|
+
* AllowDecimalPoint, AllowExponent.
|
|
111
|
+
*/
|
|
112
|
+
float: DotNetNumberStyleFlags.allowLeadingWhite |
|
|
113
|
+
DotNetNumberStyleFlags.allowTrailingWhite |
|
|
114
|
+
DotNetNumberStyleFlags.allowLeadingSign |
|
|
115
|
+
DotNetNumberStyleFlags.allowDecimalPoint |
|
|
116
|
+
DotNetNumberStyleFlags.allowExponent,
|
|
117
|
+
/**
|
|
118
|
+
* Hexadecimal parsing style.
|
|
119
|
+
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowHexSpecifier.
|
|
120
|
+
*/
|
|
121
|
+
hexNumber: DotNetNumberStyleFlags.allowLeadingWhite |
|
|
122
|
+
DotNetNumberStyleFlags.allowTrailingWhite |
|
|
123
|
+
DotNetNumberStyleFlags.allowHexSpecifier,
|
|
124
|
+
/**
|
|
125
|
+
* Basic integer parsing style.
|
|
126
|
+
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign.
|
|
127
|
+
*/
|
|
128
|
+
integer: DotNetNumberStyleFlags.allowLeadingWhite |
|
|
129
|
+
DotNetNumberStyleFlags.allowTrailingWhite |
|
|
130
|
+
DotNetNumberStyleFlags.allowLeadingSign,
|
|
131
|
+
/**
|
|
132
|
+
* Standard number parsing style.
|
|
133
|
+
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign, AllowTrailingSign,
|
|
134
|
+
* AllowDecimalPoint, AllowThousands.
|
|
135
|
+
*/
|
|
136
|
+
number: DotNetNumberStyleFlags.allowLeadingWhite |
|
|
137
|
+
DotNetNumberStyleFlags.allowTrailingWhite |
|
|
138
|
+
DotNetNumberStyleFlags.allowLeadingSign |
|
|
139
|
+
DotNetNumberStyleFlags.allowTrailingSign |
|
|
140
|
+
DotNetNumberStyleFlags.allowDecimalPoint |
|
|
141
|
+
DotNetNumberStyleFlags.allowThousands,
|
|
142
|
+
};
|
|
143
|
+
// /** @internal */
|
|
144
|
+
// export class DotNetNumberStylesInfo {
|
|
145
|
+
// static toString(styles: DotNetNumberStyleFlags): string {
|
|
146
|
+
// return this.toXmlValue(styles);
|
|
147
|
+
// }
|
|
148
|
+
// static toXmlValue(styles: DotNetNumberStyleFlags): string {
|
|
149
|
+
// if (isSameSet(styles, DotNetNumberStyles.any)) return "Any";
|
|
150
|
+
// if (isSameSet(styles, DotNetNumberStyles.currency)) return "Currency";
|
|
151
|
+
// if (isSameSet(styles, DotNetNumberStyles.float)) return "Float";
|
|
152
|
+
// if (isSameSet(styles, DotNetNumberStyles.hexNumber)) return "HexNumber";
|
|
153
|
+
// if (isSameSet(styles, DotNetNumberStyles.integer)) return "Integer";
|
|
154
|
+
// if (isSameSet(styles, DotNetNumberStyles.number)) return "Number";
|
|
155
|
+
// return CommaText.fromStringArray(Array.from(styles.values()));
|
|
156
|
+
// }
|
|
157
|
+
// static tryFromString(value: string): Result<DotNetNumberStyleFlags> {
|
|
158
|
+
// return this.tryFromXmlValue(value);
|
|
159
|
+
// }
|
|
160
|
+
// static tryFromXmlValue(value: string): Result<DotNetNumberStyleFlags> {
|
|
161
|
+
// const normalized = value.trim();
|
|
162
|
+
// if (normalized.length === 0 || normalized.toLowerCase() === "none") {
|
|
163
|
+
// return new Ok(new Set(DotNetNumberStyles.none));
|
|
164
|
+
// }
|
|
165
|
+
// const canonical = normalized.toLowerCase();
|
|
166
|
+
// if (canonical === "any") return new Ok(new Set(DotNetNumberStyles.any));
|
|
167
|
+
// if (canonical === "currency")
|
|
168
|
+
// return new Ok(new Set(DotNetNumberStyles.currency));
|
|
169
|
+
// if (canonical === "float") return new Ok(new Set(DotNetNumberStyles.float));
|
|
170
|
+
// if (canonical === "hexnumber")
|
|
171
|
+
// return new Ok(new Set(DotNetNumberStyles.hexNumber));
|
|
172
|
+
// if (canonical === "integer")
|
|
173
|
+
// return new Ok(new Set(DotNetNumberStyles.integer));
|
|
174
|
+
// if (canonical === "number")
|
|
175
|
+
// return new Ok(new Set(DotNetNumberStyles.number));
|
|
176
|
+
// const commaTextResult = CommaText.tryToStringArray(normalized);
|
|
177
|
+
// if (commaTextResult.isErr()) {
|
|
178
|
+
// return commaTextResult.createOuter(
|
|
179
|
+
// "Invalid comma-separated styles string",
|
|
180
|
+
// );
|
|
181
|
+
// }
|
|
182
|
+
// const result = new Set<DotNetNumberStyleFlags>();
|
|
183
|
+
// for (const part of commaTextResult.value) {
|
|
184
|
+
// const match = Object.values(DotNetNumberStyleFlags).find(
|
|
185
|
+
// (x) => x.toLowerCase() === part.toLowerCase(),
|
|
186
|
+
// );
|
|
187
|
+
// if (match === undefined) {
|
|
188
|
+
// return new Err(`Invalid style: ${part}`);
|
|
189
|
+
// }
|
|
190
|
+
// result.add(match);
|
|
191
|
+
// }
|
|
192
|
+
// return new Ok(result);
|
|
193
|
+
// }
|
|
194
|
+
// static tryFromXmlValueWithDefault(
|
|
195
|
+
// value: string,
|
|
196
|
+
// defaultStyles: DotNetNumberStyleFlags,
|
|
197
|
+
// ): Result<DotNetNumberStyleFlags> {
|
|
198
|
+
// if (value.trim().length === 0) {
|
|
199
|
+
// return new Ok(new Set(defaultStyles));
|
|
200
|
+
// }
|
|
201
|
+
// return this.tryFromXmlValue(value);
|
|
202
|
+
// }
|
|
203
|
+
// }
|
|
204
|
+
//# sourceMappingURL=number-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-styles.js","sourceRoot":"","sources":["../../src/code/number-styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,2CAA2C;IAC3C,iBAAiB,EAAE,CAAC;IAEpB,4CAA4C;IAC5C,kBAAkB,EAAE,CAAC;IAErB,kDAAkD;IAClD,gBAAgB,EAAE,CAAC;IAEnB,mDAAmD;IACnD,iBAAiB,EAAE,CAAC;IAEpB,sDAAsD;IACtD,gBAAgB,EAAE,EAAE;IAEpB,gDAAgD;IAChD,iBAAiB,EAAE,EAAE;IAErB,4CAA4C;IAC5C,cAAc,EAAE,EAAE;IAElB,mDAAmD;IACnD,aAAa,EAAE,GAAG;IAElB,kDAAkD;IAClD,mBAAmB,EAAE,GAAG;IAExB,uCAAuC;IACvC,iBAAiB,EAAE,GAAG;CACd,CAAC;AAWX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,6CAA6C;IAC7C,IAAI,EAAE,CAAC;IAEP,iBAAiB,EAAE,sBAAsB,CAAC,iBAAiB;IAE3D,4CAA4C;IAC5C,kBAAkB,EAAE,sBAAsB,CAAC,kBAAkB;IAE7D,kDAAkD;IAClD,gBAAgB,EAAE,sBAAsB,CAAC,gBA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-utils';
|
|
|
33
33
|
*/
|
|
34
34
|
export declare class DotNetDateTimeFormatter {
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Array of date/time style flags that are not currently supported by this implementation.
|
|
37
37
|
* Operations using these styles will fail.
|
|
38
38
|
*/
|
|
39
|
-
static readonly unsupportedStyles:
|
|
39
|
+
static readonly unsupportedStyles: (16 | 32 | 64 | 128)[];
|
|
40
40
|
private format;
|
|
41
41
|
/**
|
|
42
|
-
* The
|
|
43
|
-
*
|
|
42
|
+
* The {@link (DotNetDateTimeStyles:type)} flags that control date/time parsing behavior.
|
|
43
|
+
*
|
|
44
|
+
* Use predefined combinations from {@link (DotNetDateTimeStyles:variable)} or combine
|
|
45
|
+
* {@link (DotNetDateTimeStyleFlags:variable)} using bitwise OR.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Use predefined combination
|
|
50
|
+
* formatter.styles = DotNetDateTimeStyles.allowWhiteSpaces;
|
|
51
|
+
*
|
|
52
|
+
* // Combine individual flags
|
|
53
|
+
* formatter.styles =
|
|
54
|
+
* DotNetDateTimeStyleFlags.allowLeadingWhite |
|
|
55
|
+
* DotNetDateTimeStyleFlags.allowTrailingWhite;
|
|
56
|
+
* ```
|
|
44
57
|
*/
|
|
45
|
-
styles:
|
|
58
|
+
styles: DotNetDateTimeStyles;
|
|
46
59
|
/**
|
|
47
60
|
* The locale settings that determine date/time separators and formatting conventions.
|
|
48
61
|
*/
|
|
@@ -103,70 +116,105 @@ export declare class DotNetDateTimeFormatter {
|
|
|
103
116
|
/**
|
|
104
117
|
* Individual style flags that control date/time parsing behavior.
|
|
105
118
|
*
|
|
106
|
-
* These flags can be combined to create custom parsing rules.
|
|
119
|
+
* These flags can be combined using bitwise OR to create custom parsing rules.
|
|
107
120
|
*
|
|
108
121
|
* @example
|
|
109
122
|
* ```typescript
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
123
|
+
* const formatter = new DotNetDateTimeFormatter();
|
|
124
|
+
*
|
|
125
|
+
* // Combine multiple flags using bitwise OR
|
|
126
|
+
* formatter.styles =
|
|
127
|
+
* DotNetDateTimeStyleFlags.allowLeadingWhite |
|
|
128
|
+
* DotNetDateTimeStyleFlags.allowTrailingWhite;
|
|
115
129
|
* ```
|
|
116
130
|
*
|
|
117
131
|
* @public
|
|
118
132
|
* @category DateTime Styles
|
|
119
133
|
*/
|
|
120
|
-
export declare
|
|
134
|
+
export declare const DotNetDateTimeStyleFlags: {
|
|
121
135
|
/** Allow leading whitespace characters. */
|
|
122
|
-
|
|
136
|
+
readonly allowLeadingWhite: 1;
|
|
123
137
|
/** Allow trailing whitespace characters. */
|
|
124
|
-
|
|
138
|
+
readonly allowTrailingWhite: 2;
|
|
125
139
|
/** Allow whitespace within the date/time string. */
|
|
126
|
-
|
|
140
|
+
readonly allowInnerWhite: 4;
|
|
127
141
|
/** Do not use current date for missing date components. */
|
|
128
|
-
|
|
142
|
+
readonly noCurrentDateDefault: 8;
|
|
129
143
|
/** Adjust date/time to UTC (not implemented). */
|
|
130
|
-
|
|
144
|
+
readonly adjustToUniversal: 16;
|
|
131
145
|
/** Assume local time zone if not specified (not implemented). */
|
|
132
|
-
|
|
146
|
+
readonly assumeLocal: 32;
|
|
133
147
|
/** Assume UTC time zone if not specified (not implemented). */
|
|
134
|
-
|
|
148
|
+
readonly assumeUniversal: 64;
|
|
135
149
|
/** Preserve DateTimeKind when parsing (not implemented). */
|
|
136
|
-
|
|
137
|
-
}
|
|
150
|
+
readonly roundTripKind: 128;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The type representing possible values of {@link (DotNetDateTimeStyleFlags:variable)}.
|
|
155
|
+
*
|
|
156
|
+
* Flags can be combined using bitwise OR to create custom parsing behaviors.
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
* @category DateTime Styles
|
|
160
|
+
*/
|
|
161
|
+
export declare type DotNetDateTimeStyleFlags = (typeof DotNetDateTimeStyleFlags)[keyof typeof DotNetDateTimeStyleFlags];
|
|
138
162
|
|
|
139
163
|
/**
|
|
140
164
|
* Predefined date/time style combinations for common parsing scenarios.
|
|
141
165
|
*
|
|
142
|
-
* @
|
|
166
|
+
* Contains individual {@link (DotNetDateTimeStyleFlags:variable)} as well as common combinations.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const formatter = new DotNetDateTimeFormatter();
|
|
171
|
+
*
|
|
172
|
+
* // Use a predefined combination
|
|
173
|
+
* formatter.styles = DotNetDateTimeStyles.allowWhiteSpaces;
|
|
174
|
+
*
|
|
175
|
+
* // Or use individual flags
|
|
176
|
+
* formatter.styles = DotNetDateTimeStyles.allowLeadingWhite;
|
|
177
|
+
*
|
|
178
|
+
* // Or combine flags manually
|
|
179
|
+
* formatter.styles =
|
|
180
|
+
* DotNetDateTimeStyleFlags.allowLeadingWhite |
|
|
181
|
+
* DotNetDateTimeStyleFlags.noCurrentDateDefault;
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
143
184
|
* @category DateTime Styles
|
|
185
|
+
* @public
|
|
144
186
|
*/
|
|
145
187
|
export declare const DotNetDateTimeStyles: {
|
|
146
188
|
/** No styles - strict parsing. */
|
|
147
|
-
none:
|
|
189
|
+
readonly none: 0;
|
|
190
|
+
readonly allowLeadingWhite: 1;
|
|
191
|
+
readonly allowTrailingWhite: 2;
|
|
192
|
+
readonly allowInnerWhite: 4;
|
|
148
193
|
/**
|
|
149
194
|
* Allow whitespace in date/time strings.
|
|
150
|
-
* Includes:
|
|
195
|
+
* Includes: allowLeadingWhite, allowTrailingWhite, allowInnerWhite.
|
|
151
196
|
*/
|
|
152
|
-
allowWhiteSpaces:
|
|
197
|
+
readonly allowWhiteSpaces: number;
|
|
198
|
+
readonly noCurrentDateDefault: 8;
|
|
199
|
+
/** Adjust date/time to UTC (not implemented). */
|
|
200
|
+
readonly adjustToUniversal: 16;
|
|
201
|
+
/** Assume local time zone if not specified (not implemented). */
|
|
202
|
+
readonly assumeLocal: 32;
|
|
203
|
+
/** Assume UTC time zone if not specified (not implemented). */
|
|
204
|
+
readonly assumeUniversal: 64;
|
|
205
|
+
/** Preserve DateTimeKind when parsing (not implemented). */
|
|
206
|
+
readonly roundTripKind: 128;
|
|
153
207
|
};
|
|
154
208
|
|
|
155
209
|
/**
|
|
156
|
-
*
|
|
210
|
+
* The type representing possible values of {@link (DotNetDateTimeStyles:variable)}.
|
|
211
|
+
*
|
|
212
|
+
* This includes individual {@link (DotNetDateTimeStyleFlags:variable)} and predefined combinations.
|
|
157
213
|
*
|
|
158
214
|
* @public
|
|
159
215
|
* @category DateTime Styles
|
|
160
216
|
*/
|
|
161
|
-
export declare type
|
|
162
|
-
|
|
163
|
-
/** @internal */
|
|
164
|
-
export declare class DotNetDateTimeStylesInfo {
|
|
165
|
-
static toString(styles: DotNetDateTimeStyleSet): string;
|
|
166
|
-
static toXmlValue(styles: DotNetDateTimeStyleSet): string;
|
|
167
|
-
static tryFromString(value: string): Result<DotNetDateTimeStyleSet>;
|
|
168
|
-
static tryFromXmlValue(value: string): Result<DotNetDateTimeStyleSet>;
|
|
169
|
-
}
|
|
217
|
+
export declare type DotNetDateTimeStyles = (typeof DotNetDateTimeStyles)[keyof typeof DotNetDateTimeStyles];
|
|
170
218
|
|
|
171
219
|
/**
|
|
172
220
|
* Formatter for decimal numbers with high precision using .NET-compatible format strings.
|
|
@@ -602,21 +650,14 @@ export declare class DotNetNumberFormatter {
|
|
|
602
650
|
private precision;
|
|
603
651
|
private sections;
|
|
604
652
|
/**
|
|
605
|
-
* The
|
|
653
|
+
* The {@link (DotNetNumberStyles:variable)} that control which number formats are allowed during parsing.
|
|
606
654
|
*
|
|
607
655
|
* @example
|
|
608
656
|
* ```typescript
|
|
609
|
-
*
|
|
610
|
-
* formatter.styles = DotNetNumberStyles.number;
|
|
611
|
-
*
|
|
612
|
-
* // Or combine individual flags
|
|
613
|
-
* formatter.styles = new Set([
|
|
614
|
-
* DotNetNumberStyleId.AllowLeadingSign,
|
|
615
|
-
* DotNetNumberStyleId.AllowDecimalPoint
|
|
616
|
-
* ]);
|
|
657
|
+
* formatter.styles = DotNetNumberStyles.allowLeadingSign | DotNetNumberStyles.allowDecimalPoint;
|
|
617
658
|
* ```
|
|
618
659
|
*/
|
|
619
|
-
styles:
|
|
660
|
+
styles: DotNetNumberStyles;
|
|
620
661
|
/**
|
|
621
662
|
* The locale settings that determine decimal/thousands separators and other culture-specific formatting.
|
|
622
663
|
*/
|
|
@@ -687,37 +728,45 @@ export declare class DotNetNumberFormatter {
|
|
|
687
728
|
* ```typescript
|
|
688
729
|
* // Combine individual flags
|
|
689
730
|
* formatter.styles = new Set([
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
731
|
+
* DotNetNumberStyleFlags.AllowLeadingSign,
|
|
732
|
+
* DotNetNumberStyleFlags.AllowDecimalPoint,
|
|
733
|
+
* DotNetNumberStyleFlags.AllowThousands
|
|
693
734
|
* ]);
|
|
694
735
|
* ```
|
|
695
736
|
*
|
|
696
737
|
* @public
|
|
697
738
|
* @category Number Styles
|
|
698
739
|
*/
|
|
699
|
-
export declare
|
|
700
|
-
/** Allow currency symbol in the number string. */
|
|
701
|
-
AllowCurrencySymbol = "AllowCurrencySymbol",
|
|
702
|
-
/** Allow decimal point in the number string. */
|
|
703
|
-
AllowDecimalPoint = "AllowDecimalPoint",
|
|
704
|
-
/** Allow exponential notation (e.g., 1.23e+10). */
|
|
705
|
-
AllowExponent = "AllowExponent",
|
|
706
|
-
/** Parse the number as hexadecimal. */
|
|
707
|
-
AllowHexSpecifier = "AllowHexSpecifier",
|
|
708
|
-
/** Allow a leading plus (+) or minus (-) sign. */
|
|
709
|
-
AllowLeadingSign = "AllowLeadingSign",
|
|
740
|
+
export declare const DotNetNumberStyleFlags: {
|
|
710
741
|
/** Allow leading whitespace characters. */
|
|
711
|
-
|
|
742
|
+
readonly allowLeadingWhite: 1;
|
|
743
|
+
/** Allow trailing whitespace characters. */
|
|
744
|
+
readonly allowTrailingWhite: 2;
|
|
745
|
+
/** Allow a leading plus (+) or minus (-) sign. */
|
|
746
|
+
readonly allowLeadingSign: 4;
|
|
747
|
+
/** Allow a trailing plus (+) or minus (-) sign. */
|
|
748
|
+
readonly allowTrailingSign: 8;
|
|
712
749
|
/** Allow parentheses to indicate negative numbers. */
|
|
713
|
-
|
|
750
|
+
readonly allowParentheses: 16;
|
|
751
|
+
/** Allow decimal point in the number string. */
|
|
752
|
+
readonly allowDecimalPoint: 32;
|
|
714
753
|
/** Allow thousands separator characters. */
|
|
715
|
-
|
|
716
|
-
/** Allow
|
|
717
|
-
|
|
718
|
-
/** Allow
|
|
719
|
-
|
|
720
|
-
|
|
754
|
+
readonly allowThousands: 64;
|
|
755
|
+
/** Allow exponential notation (e.g., 1.23e+10). */
|
|
756
|
+
readonly allowExponent: 128;
|
|
757
|
+
/** Allow currency symbol in the number string. */
|
|
758
|
+
readonly allowCurrencySymbol: 256;
|
|
759
|
+
/** Parse the number as hexadecimal. */
|
|
760
|
+
readonly allowHexSpecifier: 512;
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* A set of {@link (DotNetNumberStyleFlags:variable)} flags.
|
|
765
|
+
*
|
|
766
|
+
* @public
|
|
767
|
+
* @category Number Styles
|
|
768
|
+
*/
|
|
769
|
+
export declare type DotNetNumberStyleFlags = (typeof DotNetNumberStyleFlags)[keyof typeof DotNetNumberStyleFlags];
|
|
721
770
|
|
|
722
771
|
/**
|
|
723
772
|
* Predefined number style combinations for common parsing scenarios.
|
|
@@ -733,63 +782,75 @@ export declare enum DotNetNumberStyleId {
|
|
|
733
782
|
* formatter.tryFromString('$1,234.56'); // Parses successfully
|
|
734
783
|
* ```
|
|
735
784
|
*
|
|
736
|
-
* @
|
|
785
|
+
* @public
|
|
737
786
|
* @category Number Styles
|
|
738
787
|
*/
|
|
739
788
|
export declare const DotNetNumberStyles: {
|
|
740
789
|
/** No styles - only basic digits allowed. */
|
|
741
|
-
none:
|
|
790
|
+
readonly none: 0;
|
|
791
|
+
readonly allowLeadingWhite: 1;
|
|
792
|
+
/** Allow trailing whitespace characters. */
|
|
793
|
+
readonly allowTrailingWhite: 2;
|
|
794
|
+
/** Allow a leading plus (+) or minus (-) sign. */
|
|
795
|
+
readonly allowLeadingSign: 4;
|
|
796
|
+
/** Allow a trailing plus (+) or minus (-) sign. */
|
|
797
|
+
readonly allowTrailingSign: 8;
|
|
798
|
+
/** Allow parentheses to indicate negative numbers. */
|
|
799
|
+
readonly allowParentheses: 16;
|
|
800
|
+
/** Allow decimal point in the number string. */
|
|
801
|
+
readonly allowDecimalPoint: 32;
|
|
802
|
+
/** Allow thousands separator characters. */
|
|
803
|
+
readonly allowThousands: 64;
|
|
804
|
+
/** Allow exponential notation (e.g., 1.23e+10). */
|
|
805
|
+
readonly allowExponent: 128;
|
|
806
|
+
/** Allow currency symbol in the number string. */
|
|
807
|
+
readonly allowCurrencySymbol: 256;
|
|
808
|
+
/** Parse the number as hexadecimal. */
|
|
809
|
+
readonly allowHexSpecifier: 512;
|
|
742
810
|
/**
|
|
743
811
|
* All styles allowed (except hex).
|
|
744
812
|
* Includes: AllowCurrencySymbol, AllowDecimalPoint, AllowExponent, AllowLeadingSign,
|
|
745
813
|
* AllowLeadingWhite, AllowParentheses, AllowThousands, AllowTrailingSign, AllowTrailingWhite.
|
|
746
814
|
*/
|
|
747
|
-
any:
|
|
815
|
+
readonly any: number;
|
|
748
816
|
/**
|
|
749
817
|
* Currency parsing style.
|
|
750
818
|
* Includes: AllowCurrencySymbol, AllowDecimalPoint, AllowLeadingSign, AllowLeadingWhite,
|
|
751
819
|
* AllowParentheses, AllowThousands, AllowTrailingSign, AllowTrailingWhite.
|
|
752
820
|
*/
|
|
753
|
-
currency:
|
|
821
|
+
readonly currency: number;
|
|
754
822
|
/**
|
|
755
823
|
* Floating-point parsing style.
|
|
756
824
|
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign,
|
|
757
825
|
* AllowDecimalPoint, AllowExponent.
|
|
758
826
|
*/
|
|
759
|
-
float:
|
|
827
|
+
readonly float: number;
|
|
760
828
|
/**
|
|
761
829
|
* Hexadecimal parsing style.
|
|
762
830
|
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowHexSpecifier.
|
|
763
831
|
*/
|
|
764
|
-
hexNumber:
|
|
832
|
+
readonly hexNumber: number;
|
|
765
833
|
/**
|
|
766
834
|
* Basic integer parsing style.
|
|
767
835
|
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign.
|
|
768
836
|
*/
|
|
769
|
-
integer:
|
|
837
|
+
readonly integer: number;
|
|
770
838
|
/**
|
|
771
839
|
* Standard number parsing style.
|
|
772
840
|
* Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign, AllowTrailingSign,
|
|
773
841
|
* AllowDecimalPoint, AllowThousands.
|
|
774
842
|
*/
|
|
775
|
-
number:
|
|
843
|
+
readonly number: number;
|
|
776
844
|
};
|
|
777
845
|
|
|
778
846
|
/**
|
|
779
|
-
*
|
|
847
|
+
* The type representing possible values of {@link (DotNetNumberStyles:variable)}.
|
|
848
|
+
*
|
|
849
|
+
* This includes individual {@link (DotNetNumberStyleFlags:variable)} and predefined combinations.
|
|
780
850
|
*
|
|
781
851
|
* @public
|
|
782
852
|
* @category Number Styles
|
|
783
853
|
*/
|
|
784
|
-
export declare type
|
|
785
|
-
|
|
786
|
-
/** @internal */
|
|
787
|
-
export declare class DotNetNumberStylesInfo {
|
|
788
|
-
static toString(styles: DotNetNumberStyleSet): string;
|
|
789
|
-
static toXmlValue(styles: DotNetNumberStyleSet): string;
|
|
790
|
-
static tryFromString(value: string): Result<DotNetNumberStyleSet>;
|
|
791
|
-
static tryFromXmlValue(value: string): Result<DotNetNumberStyleSet>;
|
|
792
|
-
static tryFromXmlValueWithDefault(value: string, defaultStyles: DotNetNumberStyleSet): Result<DotNetNumberStyleSet>;
|
|
793
|
-
}
|
|
854
|
+
export declare type DotNetNumberStyles = (typeof DotNetNumberStyles)[keyof typeof DotNetNumberStyles];
|
|
794
855
|
|
|
795
856
|
export { }
|