@checkdigit/time 1.0.0-PR.11-5d82 → 1.0.0-PR.11-fede
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/dist/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.js +13 -13
- package/dist/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.js.map +1 -1
- package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.js +3 -2
- package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.js.map +1 -1
- package/package.json +1 -1
- package/src/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.ts +13 -13
- package/src/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.ts +4 -4
|
@@ -18,16 +18,16 @@ function default_1(plainDate, amount) {
|
|
|
18
18
|
if (Number.isNaN(amount)) {
|
|
19
19
|
throw new TypeError('Invalid Amount');
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const result = new Date(plainDate.year, plainDate.month, plainDate.date);
|
|
22
|
+
result.setUTCHours(0, 0, 0, 0);
|
|
23
23
|
let count = 0;
|
|
24
24
|
if (amount < 0) {
|
|
25
25
|
while (count < -amount) {
|
|
26
|
-
|
|
26
|
+
result.setUTCDate(result.getUTCDate() - 1);
|
|
27
27
|
if (!(0, index_1.isUSFederalReserveBankClosed)({
|
|
28
|
-
year:
|
|
29
|
-
month:
|
|
30
|
-
date:
|
|
28
|
+
year: result.getUTCFullYear(),
|
|
29
|
+
month: result.getUTCMonth(),
|
|
30
|
+
date: result.getUTCDate(),
|
|
31
31
|
})) {
|
|
32
32
|
count++;
|
|
33
33
|
}
|
|
@@ -35,20 +35,20 @@ function default_1(plainDate, amount) {
|
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
while (count < amount) {
|
|
38
|
-
|
|
38
|
+
result.setUTCDate(result.getUTCDate() + 1);
|
|
39
39
|
if (!(0, index_1.isUSFederalReserveBankClosed)({
|
|
40
|
-
year:
|
|
41
|
-
month:
|
|
42
|
-
date:
|
|
40
|
+
year: result.getUTCFullYear(),
|
|
41
|
+
month: result.getUTCMonth(),
|
|
42
|
+
date: result.getUTCDate(),
|
|
43
43
|
})) {
|
|
44
44
|
count++;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
return {
|
|
49
|
-
year:
|
|
50
|
-
month:
|
|
51
|
-
date:
|
|
49
|
+
year: result.getUTCFullYear(),
|
|
50
|
+
month: result.getUTCMonth(),
|
|
51
|
+
date: result.getUTCDate(),
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
exports.default = default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-us-federal-reserve-bank-business-days.js","sourceRoot":"","sources":["../../../../src/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.ts"],"names":[],"mappings":";AAAA,2FAA2F;;AAE3F,mCAAkE;AAElE;;;;;;;;;;;GAWG;AACH,mBAAyB,SAAoB,EAAE,MAAc;IAC3D,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QACxB,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;KACvC;IAED,MAAM,
|
|
1
|
+
{"version":3,"file":"add-us-federal-reserve-bank-business-days.js","sourceRoot":"","sources":["../../../../src/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.ts"],"names":[],"mappings":";AAAA,2FAA2F;;AAE3F,mCAAkE;AAElE;;;;;;;;;;;GAWG;AACH,mBAAyB,SAAoB,EAAE,MAAc;IAC3D,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QACxB,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;KACvC;IAED,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACzE,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE/B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,MAAM,GAAG,CAAC,EAAE;QACd,OAAO,KAAK,GAAG,CAAC,MAAM,EAAE;YACtB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3C,IACE,CAAC,IAAA,oCAA4B,EAAC;gBAC5B,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE;gBAC7B,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE;gBAC3B,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE;aAC1B,CAAC,EACF;gBACA,KAAK,EAAE,CAAC;aACT;SACF;KACF;SAAM;QACL,OAAO,KAAK,GAAG,MAAM,EAAE;YACrB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3C,IACE,CAAC,IAAA,oCAA4B,EAAC;gBAC5B,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE;gBAC7B,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE;gBAC3B,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE;aAC1B,CAAC,EACF;gBACA,KAAK,EAAE,CAAC;aACT;SACF;KACF;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE;QAC7B,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE;QAC3B,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE;KAC1B,CAAC;AACJ,CAAC;AA1CD,4BA0CC"}
|
package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.js
CHANGED
|
@@ -21,10 +21,11 @@ function default_1(plainDate) {
|
|
|
21
21
|
const date = new Date(plainDate.year, plainDate.month, plainDate.date);
|
|
22
22
|
const year = date.getUTCFullYear();
|
|
23
23
|
const day = date.getUTCDay();
|
|
24
|
-
const
|
|
24
|
+
const formattedDate = (0, index_1.formatUtc)(date, 'yyyy-MM-dd');
|
|
25
|
+
const allUSFederalReserveBankHolidays = (0, index_2.getAllUSFederalReserveBankHolidays)(year);
|
|
25
26
|
return (day === DAY_OF_THE_WEEK_SATURDAY ||
|
|
26
27
|
day === DAY_OF_THE_WEEK_SUNDAY ||
|
|
27
|
-
|
|
28
|
+
allUSFederalReserveBankHolidays.some((holiday) => holiday.date === formattedDate || holiday.observedOn === formattedDate));
|
|
28
29
|
}
|
|
29
30
|
exports.default = default_1;
|
|
30
31
|
//# sourceMappingURL=is-us-federal-reserve-bank-closed.js.map
|
package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-us-federal-reserve-bank-closed.js","sourceRoot":"","sources":["../../../../src/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.ts"],"names":[],"mappings":";AAAA,mFAAmF;;AAEnF,0CAA2C;AAE3C,mCAAwE;AAExE,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,mBAAyB,SAAoB;IAC3C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAC7B,MAAM,+BAA+B,GAAG,IAAA,0CAAkC,EAAC,IAAI,CAAC,CAAC;IAEjF,OAAO,CACL,GAAG,KAAK,wBAAwB;QAChC,GAAG,KAAK,sBAAsB;QAC9B,+BAA+B,CAAC,IAAI,CAClC,CAAC,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"is-us-federal-reserve-bank-closed.js","sourceRoot":"","sources":["../../../../src/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.ts"],"names":[],"mappings":";AAAA,mFAAmF;;AAEnF,0CAA2C;AAE3C,mCAAwE;AAExE,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,mBAAyB,SAAoB;IAC3C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAC7B,MAAM,aAAa,GAAG,IAAA,iBAAS,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACpD,MAAM,+BAA+B,GAAG,IAAA,0CAAkC,EAAC,IAAI,CAAC,CAAC;IAEjF,OAAO,CACL,GAAG,KAAK,wBAAwB;QAChC,GAAG,KAAK,sBAAsB;QAC9B,+BAA+B,CAAC,IAAI,CAClC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,aAAa,IAAI,OAAO,CAAC,UAAU,KAAK,aAAa,CACpF,CACF,CAAC;AACJ,CAAC;AAdD,4BAcC"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/time","version":"1.0.0-PR.11-
|
|
1
|
+
{"name":"@checkdigit/time","version":"1.0.0-PR.11-fede","description":"Standard time handling","typings":"./dist/index.d.ts","main":"./dist/index.js","prettier":"@checkdigit/prettier-config","engines":{"node":">=16"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/time.git"},"author":"Check Digit, LLC","license":"MIT","bugs":{"url":"https://github.com/checkdigit/time/issues"},"homepage":"https://github.com/checkdigit/time#readme","files":["dist","/src/"],"devDependencies":{"@checkdigit/eslint-config":"7.4.0","@checkdigit/jest-config":"^2.1.0","@checkdigit/prettier-config":"^3.1.0","@checkdigit/typescript-config":"^3.2.0","@js-temporal/polyfill":"^0.4.3","rimraf":"^3.0.2","ts-node":"^10.9.1"},"scripts":{"postversion":"git push && git push --tags","lint":"eslint -f unix 'src/**/*.ts'","lint:fix":"eslint -f unix 'src/**/*.ts' --fix","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","ci:compile":"tsc --noEmit","ci:test":"jest --coverage=false","ci:coverage":"jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier"},"jest":{"preset":"@checkdigit/jest-config"},"eslintConfig":{"extends":["@checkdigit/eslint-config"],"ignorePatterns":["src/date-fns/**","src/date-fns-tz/**"]}}
|
package/src/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.ts
CHANGED
|
@@ -19,18 +19,18 @@ export default function (plainDate: PlainDate, amount: number): PlainDate {
|
|
|
19
19
|
throw new TypeError('Invalid Amount');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const result = new Date(plainDate.year, plainDate.month, plainDate.date);
|
|
23
|
+
result.setUTCHours(0, 0, 0, 0);
|
|
24
24
|
|
|
25
25
|
let count = 0;
|
|
26
26
|
if (amount < 0) {
|
|
27
27
|
while (count < -amount) {
|
|
28
|
-
|
|
28
|
+
result.setUTCDate(result.getUTCDate() - 1);
|
|
29
29
|
if (
|
|
30
30
|
!isUSFederalReserveBankClosed({
|
|
31
|
-
year:
|
|
32
|
-
month:
|
|
33
|
-
date:
|
|
31
|
+
year: result.getUTCFullYear(),
|
|
32
|
+
month: result.getUTCMonth(),
|
|
33
|
+
date: result.getUTCDate(),
|
|
34
34
|
})
|
|
35
35
|
) {
|
|
36
36
|
count++;
|
|
@@ -38,12 +38,12 @@ export default function (plainDate: PlainDate, amount: number): PlainDate {
|
|
|
38
38
|
}
|
|
39
39
|
} else {
|
|
40
40
|
while (count < amount) {
|
|
41
|
-
|
|
41
|
+
result.setUTCDate(result.getUTCDate() + 1);
|
|
42
42
|
if (
|
|
43
43
|
!isUSFederalReserveBankClosed({
|
|
44
|
-
year:
|
|
45
|
-
month:
|
|
46
|
-
date:
|
|
44
|
+
year: result.getUTCFullYear(),
|
|
45
|
+
month: result.getUTCMonth(),
|
|
46
|
+
date: result.getUTCDate(),
|
|
47
47
|
})
|
|
48
48
|
) {
|
|
49
49
|
count++;
|
|
@@ -52,8 +52,8 @@ export default function (plainDate: PlainDate, amount: number): PlainDate {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return {
|
|
55
|
-
year:
|
|
56
|
-
month:
|
|
57
|
-
date:
|
|
55
|
+
year: result.getUTCFullYear(),
|
|
56
|
+
month: result.getUTCMonth(),
|
|
57
|
+
date: result.getUTCDate(),
|
|
58
58
|
};
|
|
59
59
|
}
|
package/src/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.ts
CHANGED
|
@@ -23,14 +23,14 @@ export default function (plainDate: PlainDate): boolean {
|
|
|
23
23
|
const date = new Date(plainDate.year, plainDate.month, plainDate.date);
|
|
24
24
|
const year = date.getUTCFullYear();
|
|
25
25
|
const day = date.getUTCDay();
|
|
26
|
-
const
|
|
26
|
+
const formattedDate = formatUtc(date, 'yyyy-MM-dd');
|
|
27
|
+
const allUSFederalReserveBankHolidays = getAllUSFederalReserveBankHolidays(year);
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
30
|
day === DAY_OF_THE_WEEK_SATURDAY ||
|
|
30
31
|
day === DAY_OF_THE_WEEK_SUNDAY ||
|
|
31
|
-
|
|
32
|
-
(holiday) =>
|
|
33
|
-
holiday.date === formatUtc(date, 'yyyy-MM-dd') || holiday.observedOn === formatUtc(date, 'yyyy-MM-dd')
|
|
32
|
+
allUSFederalReserveBankHolidays.some(
|
|
33
|
+
(holiday) => holiday.date === formattedDate || holiday.observedOn === formattedDate
|
|
34
34
|
)
|
|
35
35
|
);
|
|
36
36
|
}
|