Skip to content

Commit f8566ed

Browse files
authored
Update to 2022f, etc. (#31)
* Improve timezone alias matching. * Fix zh-tw local AM/PM parsing. * Update to 2022f.
1 parent cb04428 commit f8566ed

11 files changed

Lines changed: 465 additions & 434 deletions

README.md

Lines changed: 160 additions & 160 deletions
Large diffs are not rendered by default.

ambient.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// noinspection JSUnusedGlobalSymbols
2+
3+
interface String {
4+
/**
5+
* Gets a substring beginning at the specified location and having the specified length.
6+
* (deprecation removed)
7+
* @param from The starting position of the desired substring. The index of the first character in the string is zero.
8+
* @param length The number of characters to include in the returned substring.
9+
*/
10+
substr(from: number, length?: number): string;
11+
}

package-lock.json

Lines changed: 93 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tubular/time",
3-
"version": "3.8.2",
3+
"version": "3.8.8",
44
"description": "Date/time, IANA timezones, leap seconds, TAI/UTC conversions, calendar with settable Julian/Gregorian switchover",
55
"main": "dist/cjs/index.js",
66
"module": "dist/fesm2015/index.js",
@@ -46,8 +46,8 @@
4646
"author": "Kerry Shetline <kerry@shetline.com>",
4747
"license": "MIT",
4848
"dependencies": {
49-
"@tubular/math": "^3.1.0",
50-
"@tubular/util": "^4.9.2"
49+
"@tubular/math": "^3.2.0",
50+
"@tubular/util": "^4.13.1"
5151
},
5252
"optionalDependencies": {
5353
"by-request": "^1.3.3",

src/format-parse.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ function getLocaleInfo(localeNames: string | string[]): ILocale {
790790
locale.monthsShort = [];
791791
const narrow: string[] = [];
792792
let format: DateTimeFormat;
793+
const fullTimeFormat = new DateTimeFormat(normalizeLocale(locale.name), { timeStyle: 'full', timeZone: 'UTC' });
793794

794795
for (let month = 1; month <= 12; ++month) {
795796
const date = Date.UTC(2021, month - 1, 1);
@@ -846,13 +847,28 @@ function getLocaleInfo(localeNames: string | string[]): ILocale {
846847
const date = Date.UTC(2021, 0, 1, hour, 0, 0);
847848
const value = getDatePart(format, date, 'dayPeriod');
848849
const lcValue = value.toLowerCase();
849-
850-
hourForms.add(value);
850+
let newHourForm = value;
851+
const newMeridiems = [];
851852

852853
if (value === lcValue)
853-
locale.meridiemAlt.push([value]);
854+
newMeridiems.push(value);
854855
else
855-
locale.meridiemAlt.push([lcValue, value]);
856+
newMeridiems.push(lcValue, value);
857+
858+
const fullValue = getDatePart(fullTimeFormat, date, 'dayPeriod');
859+
const lcFullValue = fullValue?.toLowerCase();
860+
861+
if (fullValue && fullValue !== value) {
862+
newHourForm += ',' + fullValue;
863+
864+
if (fullValue === lcFullValue)
865+
newMeridiems.push(fullValue);
866+
else
867+
newMeridiems.push(lcFullValue, fullValue);
868+
}
869+
870+
hourForms.add(newHourForm);
871+
locale.meridiemAlt.push(newMeridiems);
856872
}
857873

858874
if (hourForms.size < 3) {

0 commit comments

Comments
 (0)