@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.
@@ -33,16 +33,29 @@ import { Result } from '@pbkware/js-utils';
33
33
  */
34
34
  export declare class DotNetDateTimeFormatter {
35
35
  /**
36
- * Set of date/time style flags that are not currently supported by this implementation.
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: Set<DotNetDateTimeStyleId>;
39
+ static readonly unsupportedStyles: (16 | 32 | 64 | 128)[];
40
40
  private format;
41
41
  /**
42
- * The set of {@link DotNetDateTimeStyleId} flags that control date/time parsing behavior.
43
- * Currently only used for future parsing functionality.
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: DotNetDateTimeStyleSet;
58
+ styles: DotNetDateTimeStyles;
46
59
  /**
47
60
  * The locale settings that determine date/time separators and formatting conventions.
48
61
  */
@@ -103,50 +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
- * // Combine individual flags
111
- * formatter.styles = new Set([
112
- * DotNetDateTimeStyleId.AllowLeadingWhite,
113
- * DotNetDateTimeStyleId.AllowTrailingWhite
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 enum DotNetDateTimeStyleId {
134
+ export declare const DotNetDateTimeStyleFlags: {
121
135
  /** Allow leading whitespace characters. */
122
- AllowLeadingWhite = "AllowLeadingWhite",
136
+ readonly allowLeadingWhite: 1;
123
137
  /** Allow trailing whitespace characters. */
124
- AllowTrailingWhite = "AllowTrailingWhite",
138
+ readonly allowTrailingWhite: 2;
125
139
  /** Allow whitespace within the date/time string. */
126
- AllowInnerWhite = "AllowInnerWhite",
140
+ readonly allowInnerWhite: 4;
127
141
  /** Do not use current date for missing date components. */
128
- NoCurrentDateDefault = "NoCurrentDateDefault",
142
+ readonly noCurrentDateDefault: 8;
129
143
  /** Adjust date/time to UTC (not implemented). */
130
- AdjustToUniversal = "AdjustToUniversal",
144
+ readonly adjustToUniversal: 16;
131
145
  /** Assume local time zone if not specified (not implemented). */
132
- AssumeLocal = "AssumeLocal",
146
+ readonly assumeLocal: 32;
133
147
  /** Assume UTC time zone if not specified (not implemented). */
134
- AssumeUniversal = "AssumeUniversal",
148
+ readonly assumeUniversal: 64;
135
149
  /** Preserve DateTimeKind when parsing (not implemented). */
136
- RoundTripKind = "RoundTripKind"
137
- }
138
-
139
- /* Excluded from this release type: DotNetDateTimeStyles */
150
+ readonly roundTripKind: 128;
151
+ };
140
152
 
141
153
  /**
142
- * A set of {@link DotNetDateTimeStyleId} flags.
154
+ * The type representing possible values of {@link (DotNetDateTimeStyleFlags:variable)}.
155
+ *
156
+ * Flags can be combined using bitwise OR to create custom parsing behaviors.
143
157
  *
144
158
  * @public
145
159
  * @category DateTime Styles
146
160
  */
147
- export declare type DotNetDateTimeStyleSet = Set<DotNetDateTimeStyleId>;
161
+ export declare type DotNetDateTimeStyleFlags = (typeof DotNetDateTimeStyleFlags)[keyof typeof DotNetDateTimeStyleFlags];
148
162
 
149
- /* Excluded from this release type: DotNetDateTimeStylesInfo */
163
+ /**
164
+ * Predefined date/time style combinations for common parsing scenarios.
165
+ *
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
+ *
184
+ * @category DateTime Styles
185
+ * @public
186
+ */
187
+ export declare const DotNetDateTimeStyles: {
188
+ /** No styles - strict parsing. */
189
+ readonly none: 0;
190
+ readonly allowLeadingWhite: 1;
191
+ readonly allowTrailingWhite: 2;
192
+ readonly allowInnerWhite: 4;
193
+ /**
194
+ * Allow whitespace in date/time strings.
195
+ * Includes: allowLeadingWhite, allowTrailingWhite, allowInnerWhite.
196
+ */
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;
207
+ };
208
+
209
+ /**
210
+ * The type representing possible values of {@link (DotNetDateTimeStyles:variable)}.
211
+ *
212
+ * This includes individual {@link (DotNetDateTimeStyleFlags:variable)} and predefined combinations.
213
+ *
214
+ * @public
215
+ * @category DateTime Styles
216
+ */
217
+ export declare type DotNetDateTimeStyles = (typeof DotNetDateTimeStyles)[keyof typeof DotNetDateTimeStyles];
150
218
 
151
219
  /**
152
220
  * Formatter for decimal numbers with high precision using .NET-compatible format strings.
@@ -582,21 +650,14 @@ export declare class DotNetNumberFormatter {
582
650
  private precision;
583
651
  private sections;
584
652
  /**
585
- * The set of {@link DotNetNumberStyleId} flags that control which number formats are allowed during parsing.
653
+ * The {@link (DotNetNumberStyles:variable)} that control which number formats are allowed during parsing.
586
654
  *
587
655
  * @example
588
656
  * ```typescript
589
- * // Use predefined styles
590
- * formatter.styles = DotNetNumberStyles.number;
591
- *
592
- * // Or combine individual flags
593
- * formatter.styles = new Set([
594
- * DotNetNumberStyleId.AllowLeadingSign,
595
- * DotNetNumberStyleId.AllowDecimalPoint
596
- * ]);
657
+ * formatter.styles = DotNetNumberStyles.allowLeadingSign | DotNetNumberStyles.allowDecimalPoint;
597
658
  * ```
598
659
  */
599
- styles: DotNetNumberStyleSet;
660
+ styles: DotNetNumberStyles;
600
661
  /**
601
662
  * The locale settings that determine decimal/thousands separators and other culture-specific formatting.
602
663
  */
@@ -667,48 +728,129 @@ export declare class DotNetNumberFormatter {
667
728
  * ```typescript
668
729
  * // Combine individual flags
669
730
  * formatter.styles = new Set([
670
- * DotNetNumberStyleId.AllowLeadingSign,
671
- * DotNetNumberStyleId.AllowDecimalPoint,
672
- * DotNetNumberStyleId.AllowThousands
731
+ * DotNetNumberStyleFlags.AllowLeadingSign,
732
+ * DotNetNumberStyleFlags.AllowDecimalPoint,
733
+ * DotNetNumberStyleFlags.AllowThousands
673
734
  * ]);
674
735
  * ```
675
736
  *
676
737
  * @public
677
738
  * @category Number Styles
678
739
  */
679
- export declare enum DotNetNumberStyleId {
680
- /** Allow currency symbol in the number string. */
681
- AllowCurrencySymbol = "AllowCurrencySymbol",
740
+ export declare const DotNetNumberStyleFlags: {
741
+ /** Allow leading whitespace characters. */
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;
749
+ /** Allow parentheses to indicate negative numbers. */
750
+ readonly allowParentheses: 16;
682
751
  /** Allow decimal point in the number string. */
683
- AllowDecimalPoint = "AllowDecimalPoint",
752
+ readonly allowDecimalPoint: 32;
753
+ /** Allow thousands separator characters. */
754
+ readonly allowThousands: 64;
684
755
  /** Allow exponential notation (e.g., 1.23e+10). */
685
- AllowExponent = "AllowExponent",
756
+ readonly allowExponent: 128;
757
+ /** Allow currency symbol in the number string. */
758
+ readonly allowCurrencySymbol: 256;
686
759
  /** Parse the number as hexadecimal. */
687
- AllowHexSpecifier = "AllowHexSpecifier",
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];
770
+
771
+ /**
772
+ * Predefined number style combinations for common parsing scenarios.
773
+ *
774
+ * @example
775
+ * ```typescript
776
+ * // Use predefined style
777
+ * formatter.styles = DotNetNumberStyles.number;
778
+ * formatter.tryFromString('1,234.56'); // Parses successfully
779
+ *
780
+ * // Use currency style
781
+ * formatter.styles = DotNetNumberStyles.currency;
782
+ * formatter.tryFromString('$1,234.56'); // Parses successfully
783
+ * ```
784
+ *
785
+ * @public
786
+ * @category Number Styles
787
+ */
788
+ export declare const DotNetNumberStyles: {
789
+ /** No styles - only basic digits allowed. */
790
+ readonly none: 0;
791
+ readonly allowLeadingWhite: 1;
792
+ /** Allow trailing whitespace characters. */
793
+ readonly allowTrailingWhite: 2;
688
794
  /** Allow a leading plus (+) or minus (-) sign. */
689
- AllowLeadingSign = "AllowLeadingSign",
690
- /** Allow leading whitespace characters. */
691
- AllowLeadingWhite = "AllowLeadingWhite",
795
+ readonly allowLeadingSign: 4;
796
+ /** Allow a trailing plus (+) or minus (-) sign. */
797
+ readonly allowTrailingSign: 8;
692
798
  /** Allow parentheses to indicate negative numbers. */
693
- AllowParentheses = "AllowParentheses",
799
+ readonly allowParentheses: 16;
800
+ /** Allow decimal point in the number string. */
801
+ readonly allowDecimalPoint: 32;
694
802
  /** Allow thousands separator characters. */
695
- AllowThousands = "AllowThousands",
696
- /** Allow a trailing plus (+) or minus (-) sign. */
697
- AllowTrailingSign = "AllowTrailingSign",
698
- /** Allow trailing whitespace characters. */
699
- AllowTrailingWhite = "AllowTrailingWhite"
700
- }
701
-
702
- /* Excluded from this release type: DotNetNumberStyles */
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;
810
+ /**
811
+ * All styles allowed (except hex).
812
+ * Includes: AllowCurrencySymbol, AllowDecimalPoint, AllowExponent, AllowLeadingSign,
813
+ * AllowLeadingWhite, AllowParentheses, AllowThousands, AllowTrailingSign, AllowTrailingWhite.
814
+ */
815
+ readonly any: number;
816
+ /**
817
+ * Currency parsing style.
818
+ * Includes: AllowCurrencySymbol, AllowDecimalPoint, AllowLeadingSign, AllowLeadingWhite,
819
+ * AllowParentheses, AllowThousands, AllowTrailingSign, AllowTrailingWhite.
820
+ */
821
+ readonly currency: number;
822
+ /**
823
+ * Floating-point parsing style.
824
+ * Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign,
825
+ * AllowDecimalPoint, AllowExponent.
826
+ */
827
+ readonly float: number;
828
+ /**
829
+ * Hexadecimal parsing style.
830
+ * Includes: AllowLeadingWhite, AllowTrailingWhite, AllowHexSpecifier.
831
+ */
832
+ readonly hexNumber: number;
833
+ /**
834
+ * Basic integer parsing style.
835
+ * Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign.
836
+ */
837
+ readonly integer: number;
838
+ /**
839
+ * Standard number parsing style.
840
+ * Includes: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign, AllowTrailingSign,
841
+ * AllowDecimalPoint, AllowThousands.
842
+ */
843
+ readonly number: number;
844
+ };
703
845
 
704
846
  /**
705
- * A set of {@link DotNetNumberStyleId} flags.
847
+ * The type representing possible values of {@link (DotNetNumberStyles:variable)}.
848
+ *
849
+ * This includes individual {@link (DotNetNumberStyleFlags:variable)} and predefined combinations.
706
850
  *
707
851
  * @public
708
852
  * @category Number Styles
709
853
  */
710
- export declare type DotNetNumberStyleSet = Set<DotNetNumberStyleId>;
711
-
712
- /* Excluded from this release type: DotNetNumberStylesInfo */
854
+ export declare type DotNetNumberStyles = (typeof DotNetNumberStyles)[keyof typeof DotNetNumberStyles];
713
855
 
714
856
  export { }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.2"
8
+ "packageVersion": "7.58.7"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pbkware/dot-net-date-number-formatting",
3
3
  "description": "DotNet date and number formatting library",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -49,13 +49,13 @@
49
49
  "publish": "npm publish --access=public"
50
50
  },
51
51
  "devDependencies": {
52
- "@microsoft/api-extractor": "^7.58.2",
52
+ "@microsoft/api-extractor": "^7.58.7",
53
53
  "del-cli": "^7.0.0",
54
54
  "lws": "^4.2.0",
55
55
  "lws-static": "^3.1.1",
56
56
  "typedoc": "^0.28.19",
57
- "typescript": "^6.0.2",
58
- "vitest": "^4.1.4"
57
+ "typescript": "^6.0.3",
58
+ "vitest": "^4.1.6"
59
59
  },
60
60
  "dependencies": {
61
61
  "@pbkware/js-utils": "^0.9.1"
@@ -1,9 +1,8 @@
1
1
  import { Err, Ok, Result } from "@pbkware/js-utils";
2
2
  import {
3
- DotNetDateTimeStyleId,
4
- DotNetDateTimeStyleSet,
3
+ DotNetDateTimeStyleFlags,
5
4
  DotNetDateTimeStyles,
6
- } from "./datetime-style.js";
5
+ } from "./date-time-styles.js";
7
6
  import { DotNetLocaleSettings } from "./locale-settings.js";
8
7
 
9
8
  type ElementType =
@@ -302,23 +301,36 @@ function tokenizeCustom(format: string): Result<Element[]> {
302
301
  */
303
302
  export class DotNetDateTimeFormatter {
304
303
  /**
305
- * Set of date/time style flags that are not currently supported by this implementation.
304
+ * Array of date/time style flags that are not currently supported by this implementation.
306
305
  * Operations using these styles will fail.
307
306
  */
308
- static readonly unsupportedStyles = new Set<DotNetDateTimeStyleId>([
309
- DotNetDateTimeStyleId.AdjustToUniversal,
310
- DotNetDateTimeStyleId.AssumeLocal,
311
- DotNetDateTimeStyleId.AssumeUniversal,
312
- DotNetDateTimeStyleId.RoundTripKind,
313
- ]);
307
+ static readonly unsupportedStyles = [
308
+ DotNetDateTimeStyleFlags.adjustToUniversal,
309
+ DotNetDateTimeStyleFlags.assumeLocal,
310
+ DotNetDateTimeStyleFlags.assumeUniversal,
311
+ DotNetDateTimeStyleFlags.roundTripKind,
312
+ ];
314
313
 
315
314
  private format = "";
316
315
 
317
316
  /**
318
- * The set of {@link DotNetDateTimeStyleId} flags that control date/time parsing behavior.
319
- * Currently only used for future parsing functionality.
317
+ * The {@link (DotNetDateTimeStyles:type)} flags that control date/time parsing behavior.
318
+ *
319
+ * Use predefined combinations from {@link (DotNetDateTimeStyles:variable)} or combine
320
+ * {@link (DotNetDateTimeStyleFlags:variable)} using bitwise OR.
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * // Use predefined combination
325
+ * formatter.styles = DotNetDateTimeStyles.allowWhiteSpaces;
326
+ *
327
+ * // Combine individual flags
328
+ * formatter.styles =
329
+ * DotNetDateTimeStyleFlags.allowLeadingWhite |
330
+ * DotNetDateTimeStyleFlags.allowTrailingWhite;
331
+ * ```
320
332
  */
321
- styles: DotNetDateTimeStyleSet = new Set(DotNetDateTimeStyles.none);
333
+ styles: DotNetDateTimeStyles = DotNetDateTimeStyles.none;
322
334
 
323
335
  /**
324
336
  * The locale settings that determine date/time separators and formatting conventions.
@@ -512,13 +524,13 @@ export class DotNetDateTimeFormatter {
512
524
  let parseText = strValue;
513
525
 
514
526
  if (
515
- this.styles.has(DotNetDateTimeStyleId.AllowLeadingWhite) &&
516
- this.styles.has(DotNetDateTimeStyleId.AllowTrailingWhite)
527
+ this.styles & DotNetDateTimeStyles.allowLeadingWhite &&
528
+ this.styles & DotNetDateTimeStyles.allowTrailingWhite
517
529
  ) {
518
530
  parseText = parseText.trim();
519
- } else if (this.styles.has(DotNetDateTimeStyleId.AllowLeadingWhite)) {
531
+ } else if (this.styles & DotNetDateTimeStyles.allowLeadingWhite) {
520
532
  parseText = parseText.trimStart();
521
- } else if (this.styles.has(DotNetDateTimeStyleId.AllowTrailingWhite)) {
533
+ } else if (this.styles & DotNetDateTimeStyles.allowTrailingWhite) {
522
534
  parseText = parseText.trimEnd();
523
535
  }
524
536
 
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Individual style flags that control date/time parsing behavior.
3
+ *
4
+ * These flags can be combined using bitwise OR to create custom parsing rules.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const formatter = new DotNetDateTimeFormatter();
9
+ *
10
+ * // Combine multiple flags using bitwise OR
11
+ * formatter.styles =
12
+ * DotNetDateTimeStyleFlags.allowLeadingWhite |
13
+ * DotNetDateTimeStyleFlags.allowTrailingWhite;
14
+ * ```
15
+ *
16
+ * @public
17
+ * @category DateTime Styles
18
+ */
19
+ export const DotNetDateTimeStyleFlags = {
20
+ /** Allow leading whitespace characters. */
21
+ allowLeadingWhite: 1,
22
+
23
+ /** Allow trailing whitespace characters. */
24
+ allowTrailingWhite: 2,
25
+
26
+ /** Allow whitespace within the date/time string. */
27
+ allowInnerWhite: 4,
28
+
29
+ /** Do not use current date for missing date components. */
30
+ noCurrentDateDefault: 8,
31
+
32
+ /** Adjust date/time to UTC (not implemented). */
33
+ adjustToUniversal: 16,
34
+
35
+ /** Assume local time zone if not specified (not implemented). */
36
+ assumeLocal: 32,
37
+
38
+ /** Assume UTC time zone if not specified (not implemented). */
39
+ assumeUniversal: 64,
40
+
41
+ /** Preserve DateTimeKind when parsing (not implemented). */
42
+ roundTripKind: 128,
43
+ } as const;
44
+
45
+ /**
46
+ * The type representing possible values of {@link (DotNetDateTimeStyleFlags:variable)}.
47
+ *
48
+ * Flags can be combined using bitwise OR to create custom parsing behaviors.
49
+ *
50
+ * @public
51
+ * @category DateTime Styles
52
+ */
53
+ export type DotNetDateTimeStyleFlags =
54
+ (typeof DotNetDateTimeStyleFlags)[keyof typeof DotNetDateTimeStyleFlags];
55
+
56
+ /**
57
+ * Predefined date/time style combinations for common parsing scenarios.
58
+ *
59
+ * Contains individual {@link (DotNetDateTimeStyleFlags:variable)} as well as common combinations.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const formatter = new DotNetDateTimeFormatter();
64
+ *
65
+ * // Use a predefined combination
66
+ * formatter.styles = DotNetDateTimeStyles.allowWhiteSpaces;
67
+ *
68
+ * // Or use individual flags
69
+ * formatter.styles = DotNetDateTimeStyles.allowLeadingWhite;
70
+ *
71
+ * // Or combine flags manually
72
+ * formatter.styles =
73
+ * DotNetDateTimeStyleFlags.allowLeadingWhite |
74
+ * DotNetDateTimeStyleFlags.noCurrentDateDefault;
75
+ * ```
76
+ *
77
+ * @category DateTime Styles
78
+ * @public
79
+ */
80
+ export const DotNetDateTimeStyles = {
81
+ /** No styles - strict parsing. */
82
+ none: 0,
83
+
84
+ allowLeadingWhite: DotNetDateTimeStyleFlags.allowLeadingWhite,
85
+ allowTrailingWhite: DotNetDateTimeStyleFlags.allowTrailingWhite,
86
+ allowInnerWhite: DotNetDateTimeStyleFlags.allowInnerWhite,
87
+
88
+ /**
89
+ * Allow whitespace in date/time strings.
90
+ * Includes: allowLeadingWhite, allowTrailingWhite, allowInnerWhite.
91
+ */
92
+ allowWhiteSpaces:
93
+ DotNetDateTimeStyleFlags.allowLeadingWhite |
94
+ DotNetDateTimeStyleFlags.allowTrailingWhite |
95
+ DotNetDateTimeStyleFlags.allowInnerWhite,
96
+
97
+ noCurrentDateDefault: DotNetDateTimeStyleFlags.noCurrentDateDefault,
98
+
99
+ /** Adjust date/time to UTC (not implemented). */
100
+ adjustToUniversal: DotNetDateTimeStyleFlags.adjustToUniversal,
101
+
102
+ /** Assume local time zone if not specified (not implemented). */
103
+ assumeLocal: DotNetDateTimeStyleFlags.assumeLocal,
104
+
105
+ /** Assume UTC time zone if not specified (not implemented). */
106
+ assumeUniversal: DotNetDateTimeStyleFlags.assumeUniversal,
107
+
108
+ /** Preserve DateTimeKind when parsing (not implemented). */
109
+ roundTripKind: DotNetDateTimeStyleFlags.roundTripKind,
110
+ } as const;
111
+
112
+ /**
113
+ * The type representing possible values of {@link (DotNetDateTimeStyles:variable)}.
114
+ *
115
+ * This includes individual {@link (DotNetDateTimeStyleFlags:variable)} and predefined combinations.
116
+ *
117
+ * @public
118
+ * @category DateTime Styles
119
+ */
120
+ export type DotNetDateTimeStyles =
121
+ (typeof DotNetDateTimeStyles)[keyof typeof DotNetDateTimeStyles];
122
+
123
+ // const flagEntries = Object.entries(DotNetDateTimeStyleFlags);
124
+ // const flagEntriesCount = flagEntries.length;
125
+
126
+ // type LowercaseKeys<T extends Record<string, number>> = {
127
+ // [K in keyof T as Lowercase<string>]: T[K];
128
+ // };
129
+
130
+ // function lowercaseKeys<T extends Record<string, number>>(
131
+ // obj: T,
132
+ // ): LowercaseKeys<T> {
133
+ // const result = {} as Record<string, number>;
134
+ // for (const key in obj) {
135
+ // result[key.toLowerCase()] = obj[key];
136
+ // }
137
+ // return result as LowercaseKeys<T>;
138
+ // }
139
+
140
+ // const DotNetLowerCaseDateTimeStyleFlags: LowercaseKeys<
141
+ // typeof DotNetDateTimeStyleFlags
142
+ // > = lowercaseKeys(DotNetDateTimeStyleFlags);
143
+
144
+ // /** @public */
145
+ // export class DotNetDateTimeStylesStringify {
146
+ // static toString(styles: DotNetDateTimeStyles): string {
147
+ // if (styles === DotNetDateTimeStyles.none) {
148
+ // return "";
149
+ // } else {
150
+ // if (styles === DotNetDateTimeStyles.allowWhiteSpaces) {
151
+ // return "allowWhiteSpaces";
152
+ // } else {
153
+ // // For other combinations, we convert the numeric value to the corresponding flags.
154
+ // const keys = new Array<string>(flagEntriesCount);
155
+ // let count = 0;
156
+ // for (const [key, keyValue] of flagEntries) {
157
+ // if ((styles & keyValue) === keyValue) {
158
+ // keys[count++] = key;
159
+ // }
160
+ // }
161
+ // keys.length = count;
162
+ // return CommaText.fromStringArray(keys);
163
+ // }
164
+ // }
165
+ // }
166
+
167
+ // static tryFromString(value: string): Result<DotNetDateTimeStyles> {
168
+ // const trimmedValue = value.trim();
169
+ // if (trimmedValue.length === 0) {
170
+ // return new Ok(DotNetDateTimeStyles.none);
171
+ // } else {
172
+ // const lowerCasedValue = trimmedValue.toLowerCase();
173
+ // if (lowerCasedValue === "none") {
174
+ // return new Ok(DotNetDateTimeStyles.none);
175
+ // } else {
176
+ // if (lowerCasedValue === "allowwhitespaces") {
177
+ // return new Ok(DotNetDateTimeStyles.allowWhiteSpaces);
178
+ // } else {
179
+ // const toStringArrayResult = CommaText.tryToStringArray(value);
180
+ // if (toStringArrayResult.isErr()) {
181
+ // return new Err(`Invalid comma-separated list: ${value}`);
182
+ // } else {
183
+ // let result: DotNetDateTimeStyles = DotNetDateTimeStyles.none;
184
+ // const lowercaseFlagXmlValues =
185
+ // toStringArrayResult.value as (keyof typeof DotNetLowerCaseDateTimeStyleFlags)[];
186
+ // for (const flagXmlValue of lowercaseFlagXmlValues) {
187
+ // const flag = DotNetLowerCaseDateTimeStyleFlags[flagXmlValue];
188
+ // if (flag !== undefined) {
189
+ // result |= flag;
190
+ // } else {
191
+ // return new Err(`Invalid flag XmlValue: ${flagXmlValue}`);
192
+ // }
193
+ // }
194
+ // return new Ok(result);
195
+ // }
196
+ // }
197
+ // }
198
+ // }
199
+ // }
200
+ // }
package/src/code/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from "./datetime-formatter.js";
2
- export * from "./datetime-style.js";
1
+ export * from "./date-time-formatter.js";
2
+ export * from "./date-time-styles.js";
3
3
  export * from "./locale-settings.js";
4
4
  export * from "./number-formatter.js";
5
- export * from "./number-style.js";
5
+ export * from "./number-styles.js";