@checkdigit/time 5.0.0-PR.21-7813 → 5.0.0-PR.21-c1b2
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
CHANGED
|
@@ -44,7 +44,6 @@ The documentation for `date-fns-tz` is here: https://github.com/marnusw/date-fns
|
|
|
44
44
|
|
|
45
45
|
When updating the latest code from the original repositories, except making all the necessary changes to make them fully typescript compatible, please remember to carry over the patches to overcome the following issues:
|
|
46
46
|
|
|
47
|
-
-
|
|
48
|
-
- nanosecond support
|
|
47
|
+
- hours is incorrect when it's close to daylight saving timezone threshold
|
|
49
48
|
|
|
50
49
|
Please search for `[PATCH:]` in the existing codebase.
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/time","version":"5.0.0-PR.21-
|
|
1
|
+
{"name":"@checkdigit/time","version":"5.0.0-PR.21-c1b2","description":"Standard time handling","homepage":"https://github.com/checkdigit/time#readme","bugs":{"url":"https://github.com/checkdigit/time/issues"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/time.git"},"license":"MIT","author":"Check Digit, LLC","sideEffects":false,"type":"module","exports":{".":{"types":"./dist-types/index.d.ts","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-mjs","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","ci:compile":"tsc --noEmit","ci:coverage":"rimraf coverage && mkdir coverage && node --experimental-strip-types --test-timeout 600000 --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test \"src/**/*.spec.ts\"","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"node --disable-warning ExperimentalWarning --experimental-strip-types --test-timeout 600000 --test \"src/**/*.spec.ts\"","lint":"eslint --max-warnings 0 .","lint:fix":"eslint . --fix","prepublishOnly":"npm run build:dist-types && npm run build:dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"},"prettier":"@checkdigit/prettier-config","devDependencies":{"@checkdigit/eslint-config":"^11.1.0","@checkdigit/prettier-config":"^6.2.0","@checkdigit/typescript-config":"^9.0.0","rimraf":"^6.0.1"},"engines":{"node":">=22.11"}}
|
|
@@ -48,7 +48,7 @@ export const lightFormatters = {
|
|
|
48
48
|
|
|
49
49
|
// AM or PM
|
|
50
50
|
a(date: Date, token: string): string {
|
|
51
|
-
// [PATCH:] this hack is required because setHours doesn't work for hours that are
|
|
51
|
+
// [PATCH:] this hack is required because setHours doesn't work for hours that are close to daylight saving timezone threshold
|
|
52
52
|
const dayPeriodEnumValue = ((date as any)[Symbol.for('UTCHours')] ?? date.getHours()) / 12 >= 1 ? 'pm' : 'am';
|
|
53
53
|
// original:
|
|
54
54
|
// const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
|
|
@@ -69,7 +69,7 @@ export const lightFormatters = {
|
|
|
69
69
|
|
|
70
70
|
// Hour [1-12]
|
|
71
71
|
h(date: Date, token: string): string {
|
|
72
|
-
// [PATCH:] this hack is required because setHours doesn't work for hours that are
|
|
72
|
+
// [PATCH:] this hack is required because setHours doesn't work for hours that are close to daylight saving timezone threshold
|
|
73
73
|
return addLeadingZeros(((date as any)[Symbol.for('UTCHours')] ?? date.getHours()) % 12 || 12, token.length);
|
|
74
74
|
// original:
|
|
75
75
|
// return addLeadingZeros(date.getHours() % 12 || 12, token.length);
|
|
@@ -77,7 +77,7 @@ export const lightFormatters = {
|
|
|
77
77
|
|
|
78
78
|
// Hour [0-23]
|
|
79
79
|
H(date: Date, token: string): string {
|
|
80
|
-
// [PATCH:] this hack is required because setHours doesn't work for hours that are
|
|
80
|
+
// [PATCH:] this hack is required because setHours doesn't work for hours that are close to daylight saving timezone threshold
|
|
81
81
|
return addLeadingZeros((date as any)[Symbol.for('UTCHours')] ?? date.getHours(), token.length);
|
|
82
82
|
// original:
|
|
83
83
|
// return addLeadingZeros(date.getHours(), token.length);
|
|
@@ -48,7 +48,7 @@ export function constructFrom<DateType extends Date | ConstructableDate, ResultD
|
|
|
48
48
|
|
|
49
49
|
if (date && typeof date === 'object' && constructFromSymbol in date) {
|
|
50
50
|
const dateToReturn = date[constructFromSymbol](value);
|
|
51
|
-
// [PATCH:] this hack is required because setHours doesn't work for hours that are
|
|
51
|
+
// [PATCH:] this hack is required because setHours doesn't work for hours that are close to daylight saving timezone threshold
|
|
52
52
|
if ((value as any)[Symbol.for('UTCHours')] !== undefined) {
|
|
53
53
|
(dateToReturn as any)[Symbol.for('UTCHours')] = (value as any)[Symbol.for('UTCHours')];
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@ export function constructFrom<DateType extends Date | ConstructableDate, ResultD
|
|
|
57
57
|
|
|
58
58
|
if (date instanceof Date) {
|
|
59
59
|
const dateToReturn = new (date.constructor as GenericDateConstructor<ResultDate>)(value);
|
|
60
|
-
// [PATCH:] this hack is required because setHours doesn't work for hours that are
|
|
60
|
+
// [PATCH:] this hack is required because setHours doesn't work for hours that are close to daylight saving timezone threshold
|
|
61
61
|
if ((date as any)[Symbol.for('UTCHours')] !== undefined) {
|
|
62
62
|
(dateToReturn as any)[Symbol.for('UTCHours')] = (date as any)[Symbol.for('UTCHours')];
|
|
63
63
|
}
|
|
@@ -43,7 +43,7 @@ export function toZonedTime(date: Date | string | number, timeZone: string, opti
|
|
|
43
43
|
|
|
44
44
|
resultDate.setHours(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());
|
|
45
45
|
|
|
46
|
-
// [PATCH:] this hack is required because setHours doesn't work for hours that are
|
|
46
|
+
// [PATCH:] this hack is required because setHours doesn't work for hours that are close to daylight saving timezone threshold
|
|
47
47
|
(resultDate as any)[Symbol.for('UTCHours')] = d.getUTCHours();
|
|
48
48
|
|
|
49
49
|
return resultDate;
|