@@ -10,14 +10,33 @@ type AnyParentNode =
10
10
| XMLDocument ;
11
11
12
12
declare global {
13
+ /**
14
+ * The timezone identifier used for all date and time operations in tests.
15
+ * This string follows the IANA Time Zone Database format (e.g., 'America/Phoenix').
16
+ * It determines the offset and DST behavior for `Date` objects and
17
+ * related functions.
18
+ *
19
+ * @example 'America/Phoenix' // Fixed UTC-7, no DST
20
+ * @example 'Europe/London' // UTC+0 (GMT) or UTC+1 (BST) with DST
21
+ */
13
22
// eslint-disable-next-line no-var
14
23
var TZ : string | undefined ;
15
24
// eslint-disable-next-line no-var
25
+ var LOCALE_ID : string | undefined ;
26
+ /**
27
+ * The locale string defining the language and regional formatting for tests.
28
+ * This follows the BCP 47 language tag format (e.g., 'en-US'). It ensures consistent formatting
29
+ * across tests.
30
+ *
31
+ * @example 'en-US' // American English
32
+ */
33
+ // eslint-disable-next-line no-var
16
34
var IMPLEMENTATION : string | undefined ;
17
35
}
18
36
19
37
globalThis . IMPLEMENTATION = typeof IMPLEMENTATION === 'string' ? IMPLEMENTATION : undefined ;
20
38
globalThis . TZ = typeof TZ === 'string' ? TZ : undefined ;
39
+ globalThis . LOCALE_ID = typeof LOCALE_ID === 'string' ? LOCALE_ID : undefined ;
21
40
22
41
const namespaces : Record < string , string > = {
23
42
xhtml : 'http://www.w3.org/1999/xhtml' ,
@@ -338,3 +357,7 @@ export const getNonNamespaceAttributes = (element: Element): readonly Attr[] =>
338
357
339
358
return attrs . filter ( ( { name } ) => name !== 'xmlns' && ! name . startsWith ( 'xmlns:' ) ) ;
340
359
} ;
360
+
361
+ export const getDefaultDateTimeLocale = ( ) : string => {
362
+ return new Date ( ) . toLocaleString ( LOCALE_ID , { timeZone : TZ } ) ;
363
+ } ;
0 commit comments