Skip to content

Commit

Permalink
Merge branch 'main' of github.com:bart-krakowski/get-week-info-polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-krakowski committed Aug 1, 2024
2 parents 66de9a3 + 3db808c commit 71fef24
Show file tree
Hide file tree
Showing 2 changed files with 729 additions and 1,850 deletions.
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,35 @@ npm install @bart-krakowski/get-week-info-polyfill
## Usage

```js
require('intl-locale-get-week-info');
require('@bart-krakowski/get-week-info-polyfill')

const he = new Intl.Locale("he"); // Hebrew (Israel)
console.log(he.getWeekInfo()); // { firstDay: 7, weekend: [5, 6], minimalDays: 1 }
const he = new Intl.Locale('he') // Hebrew (Israel)
console.log(he.getWeekInfo()) // { firstDay: 7, weekend: [5, 6], minimalDays: 1 }

const af = new Intl.Locale("af"); // Afrikaans (South Africa)
console.log(af.getWeekInfo()); // { firstDay: 7, weekend: [6, 7], minimalDays: 1 }
const af = new Intl.Locale('af') // Afrikaans (South Africa)
console.log(af.getWeekInfo()) // { firstDay: 7, weekend: [6, 7], minimalDays: 1 }

const enGB = new Intl.Locale("en-GB"); // English (United Kingdom)
console.log(enGB.getWeekInfo()); // { firstDay: 1, weekend: [6, 7], minimalDays: 4 }
const enGB = new Intl.Locale('en-GB') // English (United Kingdom)
console.log(enGB.getWeekInfo()) // { firstDay: 1, weekend: [6, 7], minimalDays: 4 }

const arAF = new Intl.Locale("ar-AF"); // Arabic (Afghanistan)
console.log(arAF.getWeekInfo()); // { firstDay: 6, weekend: [4, 5], minimalDays: 1 }
const arAF = new Intl.Locale('ar-AF') // Arabic (Afghanistan)
console.log(arAF.getWeekInfo()) // { firstDay: 6, weekend: [4, 5], minimalDays: 1 }

const dvMV = new Intl.Locale("dv-MV"); // Divehi (Maldives)
console.log(dvMV.getWeekInfo()); // { firstDay: 5, weekend: [6, 7], minimalDays: 1 }
const dvMV = new Intl.Locale('dv-MV') // Divehi (Maldives)
console.log(dvMV.getWeekInfo()) // { firstDay: 5, weekend: [6, 7], minimalDays: 1 }
```

## API

`Intl.Locale.prototype.getWeekInfo
`Returns an object containing week information for the locale.
`Intl.Locale.prototype.getWeekInfo` returns an object containing week information for the locale.

### Returns:

- `WeekInfo`
An object with the following properties:
An object with the following properties:
- `firstDay (number)`
An integer between 1 (Monday) and 7 (Sunday) indicating the first day of the week for the locale. Commonly 1, 5, 6, or 7.
An integer between 1 (Monday) and 7 (Sunday) indicating the first day of the week for the locale. Commonly 1, 5, 6, or 7.
- `weekend (number[])`
An array of integers between 1 and 7 indicating the weekend days for the locale. This is usually continuous because UTS 35 stores weekendStart and weekendEnd instead.
An array of integers between 1 and 7 indicating the weekend days for the locale. This is usually continuous because UTS 35 stores weekendStart and weekendEnd instead.
- `minimalDays (number)`
An integer between 1 and 7 (commonly 1 and 4) indicating the minimal days required in the first week of a month or year, for week-of-year or week-of-month calculations (e.g. The 20th week of the year). For example, in the [ISO 8601 calendar](https://en.wikipedia.org/wiki/ISO_8601), the first week of a year must have at least 4 days in this year, so if January 1 is a Friday, Saturday, or Sunday, it will be numbered as part of the last week of the previous year.

An integer between 1 and 7 (commonly 1 and 4) indicating the minimal days required in the first week of a month or year, for week-of-year or week-of-month calculations (e.g. The 20th week of the year). For example, in the [ISO 8601 calendar](https://en.wikipedia.org/wiki/ISO_8601), the first week of a year must have at least 4 days in this year, so if January 1 is a Friday, Saturday, or Sunday, it will be numbered as part of the last week of the previous year.
Loading

0 comments on commit 71fef24

Please sign in to comment.