-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
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 GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 18 on macos-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 18 on windows-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 20 on ubuntu-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 20 on macos-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 20 on windows-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 21 on ubuntu-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 21 on macos-latest
Check failure on line 30 in lib/get-holiday.ts GitHub Actions / Node.js 21 on windows-latest
|
||
} |