Skip to content

Commit

Permalink
Holidays update
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzyCzech committed Apr 9, 2024
1 parent f174a41 commit 9ada5ec
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions lib/get-holiday.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import holidays from './holidays.json'
import {DateTime} from "luxon";

const holidays = {
"01-01": "Den obnovy samostatného českého státu",
"01-05": "Svátek práce",
"08-05": "Den vítězství (1945)",
"05-07": "Den slovanských věrozvěstů Cyrila a Metoděje",
"06-07": "Den upálení mistra Jana Husa (1415)",
"28-09": "Den české státnosti",
"28-10": "Den vzniku samostatného československého státu (1918)",
"17-11": "Den boje za svobodu a demokracii (1939 a 1989)",
"24-12": "Štědrý den",
"25-12": "První svátek vánoční",
"26-12": "Druhý svátek vánoční"
}

/**
* Check if the given date is a holiday
* @param date
*/
export function isHoliday(date: DateTime): boolean {
return date.toFormat('MM-dd') in holidays;
}

/**
* Get the name of the holiday for the given date
* @param date
*/
export function getHoliday(date: DateTime): string | undefined {
const key = date.toFormat('MM-dd')
if (holidays[key]) {
return holidays[key]
}
return date.toFormat('MM-dd') in holidays ? holidays[date.toFormat('MM-dd')] : undefined;

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on ubuntu-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on macos-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on windows-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 21 on ubuntu-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 21 on macos-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.

Check failure on line 30 in lib/get-holiday.ts

View workflow job for this annotation

GitHub Actions / Node.js 21 on windows-latest

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "01-01": string; "01-05": string; "08-05": string; "05-07": string; "06-07": string; "28-09": string; "28-10": string; "17-11": string; "24-12": string; "25-12": string; "26-12": string; }'.
}

0 comments on commit 9ada5ec

Please sign in to comment.