-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.d.ts
51 lines (47 loc) · 2.39 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
// Created on the basis of http://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html
export as namespace weekstart;
export type DayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;
/**
* Return first day of week for country/region code.
*
* Based on data from:
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
* - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)
*
* @example
* getWeekStartByRegion('PNG'); // 1
* getWeekStartByRegion('qa'); // 6
* getWeekStartByRegion(462); // 5
*
* @param {number | string} regionCode
* ISO 3166 Alpha-2, Alpha-3 or numeric code.
* @return {number}
* Code of first day of week for the given country/region code:
* 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
*/
export function getWeekStartByRegion(
regionCode: number | string
): DayOfWeek;
/**
* Return first day of week for locale identifier.
*
* Based on data from:
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html)
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html)
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
* - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)
*
* @example
* getWeekStartByLocale('no'); // 1
* getWeekStartByLocale('Pa_Guru'); // 0
* getWeekStartByLocale('fr-DZ'); // 6
*
* @param {string} locale
* Locale identifier.
* @return {number}
* Code of first day of week for the given locale identifier:
* 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
*/
export function getWeekStartByLocale(
locale: string
): DayOfWeek;