@brightspace-ui/intl 3.34.3 → 3.35.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/lib/_timeZones/mapper.js +0 -17
- package/lib/dateTime.js +3 -1
- package/lib/timeZones.js +1 -21
- package/package.json +1 -1
package/lib/_timeZones/mapper.js
CHANGED
|
@@ -139,23 +139,6 @@ export class TimeZoneMapper {
|
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Get all timeZones for a specific region
|
|
143
|
-
* @param {string} regionCode - ISO 3166-1 alpha-2 region code
|
|
144
|
-
* @returns {string[]} Array of timeZone identifiers
|
|
145
|
-
*/
|
|
146
|
-
getTimeZonesForRegion(regionCode) {
|
|
147
|
-
this._ensureLoaded();
|
|
148
|
-
const timeZones = [];
|
|
149
|
-
|
|
150
|
-
for (const [timeZone, info] of this.mappings.entries()) {
|
|
151
|
-
if (info.regionCode === regionCode.toUpperCase()) {
|
|
152
|
-
timeZones.push(timeZone);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return timeZones.sort();
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
142
|
* Load timeZone mappings from a single combined object
|
|
160
143
|
* @param {Object} timeZoneData - Combined timeZone data object
|
|
161
144
|
*/
|
package/lib/dateTime.js
CHANGED
|
@@ -367,6 +367,7 @@ function getParts() {
|
|
|
367
367
|
result.push('M');
|
|
368
368
|
break;
|
|
369
369
|
case 'yyyy':
|
|
370
|
+
case 'yy':
|
|
370
371
|
result.push('yyyy');
|
|
371
372
|
break;
|
|
372
373
|
}
|
|
@@ -1099,7 +1100,8 @@ export function formatDate(date, options) {
|
|
|
1099
1100
|
'MMM': descriptor.calendar.months.short[date.getMonth()],
|
|
1100
1101
|
'MM': prePadByZero((date.getMonth() + 1), 2),
|
|
1101
1102
|
'M': (date.getMonth() + 1).toString(),
|
|
1102
|
-
'yyyy': date.getFullYear().toString()
|
|
1103
|
+
'yyyy': date.getFullYear().toString(),
|
|
1104
|
+
'yy': date.getFullYear().toString().substr(2, 2)
|
|
1103
1105
|
};
|
|
1104
1106
|
|
|
1105
1107
|
const value = processPattern(format, replacements);
|
package/lib/timeZones.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
import { getDocumentLocaleSettings } from './common.js';
|
|
2
2
|
import { TimeZoneMapper } from './_timeZones/mapper.js';
|
|
3
3
|
|
|
4
|
-
let timeZoneData;
|
|
5
|
-
getDocumentLocaleSettings().addChangeListener(() => timeZoneData = null);
|
|
6
|
-
|
|
7
4
|
const tzMap = {
|
|
8
5
|
'Asia/Calcutta': 'Asia/Kolkata',
|
|
9
6
|
};
|
|
10
7
|
|
|
11
8
|
let timeZoneIdentifiers = null;
|
|
12
|
-
|
|
9
|
+
function getTimeZoneIdentifiers() {
|
|
13
10
|
if (timeZoneIdentifiers === null) {
|
|
14
11
|
timeZoneIdentifiers = Intl.supportedValuesOf?.('timeZone').map(t => tzMap[t] || t) || [];
|
|
15
12
|
}
|
|
16
13
|
return timeZoneIdentifiers;
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
export async function getTimeZonesData(region, modules) {
|
|
20
|
-
let timeZones;
|
|
21
|
-
const mapper = new TimeZoneMapper(modules);
|
|
22
|
-
await mapper.loadMappings();
|
|
23
|
-
|
|
24
|
-
if (region) {
|
|
25
|
-
timeZones = new Intl.Locale(`en-${region}`).getTimeZones?.();
|
|
26
|
-
if (!timeZones?.length) {
|
|
27
|
-
timeZones = mapper.getTimeZonesForRegion(region);
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
if (timeZoneData) return timeZoneData;
|
|
31
|
-
timeZones = getTimeZoneIdentifiers();
|
|
32
|
-
}
|
|
33
|
-
return await Promise.all(timeZones.map(l => getTimeZoneData(l, { mapper })));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
16
|
export async function getTimeZoneData(
|
|
37
17
|
identifier = getDocumentLocaleSettings().timezone.identifier,
|
|
38
18
|
{
|
package/package.json
CHANGED