Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fishbowler/workingday-uk
Node package to determine if a date is a working day in the UK, according to UK government website
https://github.com/fishbowler/workingday-uk
Last synced: 16 days ago
JSON representation
Node package to determine if a date is a working day in the UK, according to UK government website
- Host: GitHub
- URL: https://github.com/fishbowler/workingday-uk
- Owner: Fishbowler
- License: mit
- Created: 2019-06-07T18:05:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-07T12:35:11.000Z (9 months ago)
- Last Synced: 2024-12-27T22:56:43.050Z (26 days ago)
- Language: JavaScript
- Size: 95.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# workingday-uk
Promise-based node package to determine if a date is a working day in the UK, based on being a weekday, and not a bank holiday, according to the UK government website.## Usage
```js
fn([string isoDate]|[Date date], [boolean offline])
```* Takes an optional Date object or a string in the format YYYY-mm-DD. Default: today
* Takes an optional boolean whether to work offline. Default: true (using a local copy of the GOV.UK bank holiday API response)### Examples
Use with no params for today
```js
const isWorkingDay = require('workingday-uk')isWorkingDay()
.then(iwd => {
console.log('Today is a working day? ' + iwd)
})
```Use with a date
```js
const isWorkingDay = require('workingday-uk')const dateToCheck = new Date(2000, 0, 1) //1st Jan 2000
isWorkingDay(dateToCheck)
.then(iwd => {
console.log(iwd) //False
})
```Use with a date string of YYYY-MM-DD
```js
const isWorkingDay = require('workingday-uk')const dateToCheck = '2019-12-24'
isWorkingDay(dateToCheck)
.then(iwd => {
console.log(iwd) //True - Tuesday, and not a bank holiday
})
```Check online for today
```js
const isWorkingDay = require('workingday-uk')isWorkingDay(false)
.then(iwd => {
console.log('Today is a working day? ' + iwd)
})
```Check online for Christmas Day
```js
const isWorkingDay = require('workingday-uk')const dateToCheck = '2019-12-25'
isWorkingDay(dateToCheck, false)
.then(iwd => {
console.log(iwd) //False
})
```