-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 562b22d
Showing
14 changed files
with
2,530 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
registry-url: 'https://registry.npmjs.org/' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build package | ||
run: npm run build | ||
|
||
- name: Publish to npm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npm publish --access public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# `Intl.Locale.prototype.getWeekInfo()` polyfill | ||
|
||
This package provides a polyfill for the Intl.Locale API, adding the getWeekInfo method if it is not already available in the environment. | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install intl-locale-get-week-info | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
require('intl-locale-get-week-info'); | ||
|
||
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 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 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. | ||
|
||
### Returns: | ||
- `WeekInfo` | ||
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. | ||
- `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. | ||
- `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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + TS</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@bart-krakowski/get-week-info-polyfill", | ||
"author": { | ||
"name": "Bart Krakowski", | ||
"email": "[email protected]" | ||
}, | ||
"main": "dist/index.js", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.5.3", | ||
"vite": "^5.3.3" | ||
} | ||
} |
Oops, something went wrong.