chronal 0.0.23 → 0.0.25
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/esm/lib/format-date.d.ts.map +1 -1
- package/esm/lib/format-date.js +3 -1
- package/esm/lib/is-tomorrow.d.ts.map +1 -1
- package/esm/lib/is-tomorrow.js +5 -6
- package/esm/lib/is-yesterday.d.ts.map +1 -1
- package/esm/lib/is-yesterday.js +5 -6
- package/package.json +1 -1
- package/script/lib/format-date.d.ts.map +1 -1
- package/script/lib/format-date.js +3 -1
- package/script/lib/is-tomorrow.d.ts.map +1 -1
- package/script/lib/is-tomorrow.js +5 -6
- package/script/lib/is-yesterday.d.ts.map +1 -1
- package/script/lib/is-yesterday.js +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-date.d.ts","sourceRoot":"","sources":["../../src/lib/format-date.ts"],"names":[],"mappings":"AAKA,KAAK,aAAa,GAAG;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"format-date.d.ts","sourceRoot":"","sources":["../../src/lib/format-date.ts"],"names":[],"mappings":"AAKA,KAAK,aAAa,GAAG;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAwIF;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAaR"}
|
package/esm/lib/format-date.js
CHANGED
|
@@ -85,7 +85,7 @@ function getPartsWithTZ(date, locale, tz) {
|
|
|
85
85
|
year: 0,
|
|
86
86
|
month: 0,
|
|
87
87
|
day: 0,
|
|
88
|
-
dayOfWeek:
|
|
88
|
+
dayOfWeek: 0,
|
|
89
89
|
hour: 0,
|
|
90
90
|
minute: 0,
|
|
91
91
|
second: 0,
|
|
@@ -113,6 +113,8 @@ function getPartsWithTZ(date, locale, tz) {
|
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
// Derive dayOfWeek from the TZ-adjusted date components, not OS local time
|
|
117
|
+
p.dayOfWeek = new Date(Date.UTC(p.year, p.month - 1, p.day)).getUTCDay();
|
|
116
118
|
return p;
|
|
117
119
|
}
|
|
118
120
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-tomorrow.d.ts","sourceRoot":"","sources":["../../src/lib/is-tomorrow.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"is-tomorrow.d.ts","sourceRoot":"","sources":["../../src/lib/is-tomorrow.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAyC/E"}
|
package/esm/lib/is-tomorrow.js
CHANGED
|
@@ -29,13 +29,12 @@ export function isTomorrow(date, options = {}) {
|
|
|
29
29
|
}
|
|
30
30
|
// Timezone-aware comparison
|
|
31
31
|
const formatter = getDTF("en-US", timezone);
|
|
32
|
-
const nowParts = formatter.formatToParts(now);
|
|
33
32
|
const getPartValue = (parts, type) => parts.find((p) => p.type === type)?.value || "0";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
const tomorrowDate = new Date(
|
|
33
|
+
// +24h from now always lands in tomorrow for any fixed-offset timezone.
|
|
34
|
+
// Date.UTC(localYear, localMonth-1, localDay+1) was wrong: it creates UTC
|
|
35
|
+
// midnight from local date parts, which represents the previous evening in
|
|
36
|
+
// timezones behind UTC (e.g. UTC-3 São Paulo).
|
|
37
|
+
const tomorrowDate = new Date(now.getTime() + 24 * 60 * 60 * 1000);
|
|
39
38
|
const tomorrowParts = formatter.formatToParts(tomorrowDate);
|
|
40
39
|
const tomorrowYear = getPartValue(tomorrowParts, "year");
|
|
41
40
|
const tomorrowMonth = getPartValue(tomorrowParts, "month");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-yesterday.d.ts","sourceRoot":"","sources":["../../src/lib/is-yesterday.ts"],"names":[],"mappings":"AAGA,KAAK,kBAAkB,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"is-yesterday.d.ts","sourceRoot":"","sources":["../../src/lib/is-yesterday.ts"],"names":[],"mappings":"AAGA,KAAK,kBAAkB,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAyCjF"}
|
package/esm/lib/is-yesterday.js
CHANGED
|
@@ -29,13 +29,12 @@ export function isYesterday(date, options = {}) {
|
|
|
29
29
|
}
|
|
30
30
|
// Timezone-aware comparison
|
|
31
31
|
const formatter = getDTF("en-US", timezone);
|
|
32
|
-
const nowParts = formatter.formatToParts(now);
|
|
33
32
|
const getPartValue = (parts, type) => parts.find((p) => p.type === type)?.value || "0";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
const yesterdayDate = new Date(
|
|
33
|
+
// -24h from now always lands in yesterday for any fixed-offset timezone.
|
|
34
|
+
// Date.UTC(localYear, localMonth-1, localDay-1) was wrong: it creates UTC
|
|
35
|
+
// midnight from local date parts, which represents the previous evening in
|
|
36
|
+
// timezones behind UTC (e.g. UTC-3 São Paulo).
|
|
37
|
+
const yesterdayDate = new Date(now.getTime() - 24 * 60 * 60 * 1000);
|
|
39
38
|
const yesterdayParts = formatter.formatToParts(yesterdayDate);
|
|
40
39
|
const yesterdayYear = getPartValue(yesterdayParts, "year");
|
|
41
40
|
const yesterdayMonth = getPartValue(yesterdayParts, "month");
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-date.d.ts","sourceRoot":"","sources":["../../src/lib/format-date.ts"],"names":[],"mappings":"AAKA,KAAK,aAAa,GAAG;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"format-date.d.ts","sourceRoot":"","sources":["../../src/lib/format-date.ts"],"names":[],"mappings":"AAKA,KAAK,aAAa,GAAG;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAwIF;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAaR"}
|
|
@@ -88,7 +88,7 @@ function getPartsWithTZ(date, locale, tz) {
|
|
|
88
88
|
year: 0,
|
|
89
89
|
month: 0,
|
|
90
90
|
day: 0,
|
|
91
|
-
dayOfWeek:
|
|
91
|
+
dayOfWeek: 0,
|
|
92
92
|
hour: 0,
|
|
93
93
|
minute: 0,
|
|
94
94
|
second: 0,
|
|
@@ -116,6 +116,8 @@ function getPartsWithTZ(date, locale, tz) {
|
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
// Derive dayOfWeek from the TZ-adjusted date components, not OS local time
|
|
120
|
+
p.dayOfWeek = new Date(Date.UTC(p.year, p.month - 1, p.day)).getUTCDay();
|
|
119
121
|
return p;
|
|
120
122
|
}
|
|
121
123
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-tomorrow.d.ts","sourceRoot":"","sources":["../../src/lib/is-tomorrow.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"is-tomorrow.d.ts","sourceRoot":"","sources":["../../src/lib/is-tomorrow.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAyC/E"}
|
|
@@ -32,13 +32,12 @@ function isTomorrow(date, options = {}) {
|
|
|
32
32
|
}
|
|
33
33
|
// Timezone-aware comparison
|
|
34
34
|
const formatter = (0, dtf_js_1.getDTF)("en-US", timezone);
|
|
35
|
-
const nowParts = formatter.formatToParts(now);
|
|
36
35
|
const getPartValue = (parts, type) => parts.find((p) => p.type === type)?.value || "0";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
const tomorrowDate = new Date(
|
|
36
|
+
// +24h from now always lands in tomorrow for any fixed-offset timezone.
|
|
37
|
+
// Date.UTC(localYear, localMonth-1, localDay+1) was wrong: it creates UTC
|
|
38
|
+
// midnight from local date parts, which represents the previous evening in
|
|
39
|
+
// timezones behind UTC (e.g. UTC-3 São Paulo).
|
|
40
|
+
const tomorrowDate = new Date(now.getTime() + 24 * 60 * 60 * 1000);
|
|
42
41
|
const tomorrowParts = formatter.formatToParts(tomorrowDate);
|
|
43
42
|
const tomorrowYear = getPartValue(tomorrowParts, "year");
|
|
44
43
|
const tomorrowMonth = getPartValue(tomorrowParts, "month");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-yesterday.d.ts","sourceRoot":"","sources":["../../src/lib/is-yesterday.ts"],"names":[],"mappings":"AAGA,KAAK,kBAAkB,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"is-yesterday.d.ts","sourceRoot":"","sources":["../../src/lib/is-yesterday.ts"],"names":[],"mappings":"AAGA,KAAK,kBAAkB,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAyCjF"}
|
|
@@ -32,13 +32,12 @@ function isYesterday(date, options = {}) {
|
|
|
32
32
|
}
|
|
33
33
|
// Timezone-aware comparison
|
|
34
34
|
const formatter = (0, dtf_js_1.getDTF)("en-US", timezone);
|
|
35
|
-
const nowParts = formatter.formatToParts(now);
|
|
36
35
|
const getPartValue = (parts, type) => parts.find((p) => p.type === type)?.value || "0";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
const yesterdayDate = new Date(
|
|
36
|
+
// -24h from now always lands in yesterday for any fixed-offset timezone.
|
|
37
|
+
// Date.UTC(localYear, localMonth-1, localDay-1) was wrong: it creates UTC
|
|
38
|
+
// midnight from local date parts, which represents the previous evening in
|
|
39
|
+
// timezones behind UTC (e.g. UTC-3 São Paulo).
|
|
40
|
+
const yesterdayDate = new Date(now.getTime() - 24 * 60 * 60 * 1000);
|
|
42
41
|
const yesterdayParts = formatter.formatToParts(yesterdayDate);
|
|
43
42
|
const yesterdayYear = getPartValue(yesterdayParts, "year");
|
|
44
43
|
const yesterdayMonth = getPartValue(yesterdayParts, "month");
|