Commit b2591295 authored by Johannes Bill's avatar Johannes Bill

add holiday calculation cache

parent 3081c4d9
......@@ -29,6 +29,15 @@ const variableOffsets = {
603: 60
};
const holidayCache = {};
function getDateHolidays(countryCode) {
if (!(countryCode in holidayCache)) {
holidayCache[countryCode] = new DateHolidays(countryCode).getHolidays(2022);
}
return holidayCache[countryCode];
}
function Holidays(year) {
function getEasterSunday() {
if (!easterSundays[year]) {
......@@ -143,9 +152,7 @@ function Holidays(year) {
this.getAllHolidays = function (info, epochSpan, cb) {
if (info.countryCode && ['DE', 'GB', 'US'].includes(info.countryCode)) {
const dateHolidays = new DateHolidays(info.countryCode);
const holidayDays = dateHolidays
.getHolidays(2021)
const holidayDays = getDateHolidays(info.countryCode)
.filter(x => x.type === 'public')
.map(x => {
const dateDay = x.date.slice(0, 10); // strip hours
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment