forked from sfakir/feiertagejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
111 lines (99 loc) · 2.52 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
declare type Region =
| 'BW' // Baden-Württemberg
| 'BY' // Bayern
| 'BE' // Berlin
| 'BB' // Brandenburg
| 'HB' // Bremen
| 'HE' // Hessen
| 'HH' // Hamburg
| 'MV' // Mecklenburg-Vorpommern
| 'NI' // Niedersachsen
| 'NW' // Nordrhein-Westfalen
| 'RP' // Rheinland-Pfalz
| 'SL' // Saarland
| 'SN' // Sachsen
| 'ST' // Sachsen-Anhalt
| 'SH' // Schleswig-Holstein
| 'TH' // Thüringen
| 'BUND' // Gesamt-Deutschland
| 'ALL';
declare type Holiday = {
name: HolidayType;
date: Date;
trans: (lang: string | undefined) => string;
dateString: string;
equals: (date: Date) => boolean;
};
declare type HolidayType =
| 'NEUJAHRSTAG'
| 'HEILIGEDREIKOENIGE'
| 'KARFREITAG'
| 'OSTERSONNTAG'
| 'OSTERMONTAG'
| 'TAG_DER_ARBEIT'
| 'CHRISTIHIMMELFAHRT'
| 'MARIAHIMMELFAHRT'
| 'PFINGSTSONNTAG'
| 'PFINGSTMONTAG'
| 'FRONLEICHNAM'
| 'DEUTSCHEEINHEIT'
| 'REFORMATIONSTAG'
| 'ALLERHEILIGEN'
| 'BUBETAG'
| 'ERSTERWEIHNACHTSFEIERTAG'
| 'ZWEITERWEIHNACHTSFEIERTAG';
/**
* Map of {@link HolidayType} to translation string.
*/
export type TranslationTable = {
[key: string]: string;
};
/**
* adds a translation for the holidays (e.g. english).
* This also allows to override the German names.
* Hint: Interpolates German for missing translations
* @param {string} isoCode of the new language
* @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg
*/
declare function addTranslation(
isoCode: string,
newTranslation: TranslationTable,
): void;
/**
* Set a language to default language
* @param {string} isoCode
*/
declare function setLanguage(isoCode: string): void;
/**
* Get currently set language
* @returns {string}
*/
declare function getLanguage(): string;
// holidays api
/**
* Checks if a specific date is sunday or holiday.
* @param date
* @param region
* @returns {boolean}
*/
declare function isSunOrHoliday(date: Date, region: Region): boolean;
/**
* Check is specific date is holiday.
* @param date
* @param {Region} region two character {@link Region} code
* @returns {boolean}
*/
declare function isHoliday(date: Date, region: Region): boolean;
declare function getHolidayByDate(date: Date, region: Region): Holiday | void;
declare function isSpecificHoliday(
date: Date,
holidayName: HolidayType,
region: Region,
): boolean;
/**
* Returns all holidays of a year in a {@link Region}.
* @param year
* @param region
* @returns {Array.<Holiday>}
*/
declare function getHolidays(year: number | string, region: Region): Holiday[];