https://github.com/remithomas/localized-dst
Determine if a date is in daylight savings time by country/state/city
https://github.com/remithomas/localized-dst
Last synced: about 1 year ago
JSON representation
Determine if a date is in daylight savings time by country/state/city
- Host: GitHub
- URL: https://github.com/remithomas/localized-dst
- Owner: remithomas
- Created: 2021-08-24T14:27:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-10-03T15:36:24.000Z (over 3 years ago)
- Last Synced: 2025-01-30T11:11:16.592Z (over 1 year ago)
- Language: TypeScript
- Size: 210 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# localized DST
`Determine if a date is in daylight savings time by country/state/city`
## Motivation
I wasn't able to find a correct library to do the simple task `is my date during DST (Daylight Savings Time`. Every library was old or unconstistant because I learnt the hard way but not every Country/State/City have the same DST...
This is based on the information of https://www.timeanddate.com/time/dst/
## Installation
```bash
npm install localized-dst
```
or
```bash
yarn add localized-dst
```
## How to use it
```ts
import { isDst } from 'localized-dst';
// DST info for Canada, Québec, Montréal
console.log(
isDst(new Date('2019-08-14 21:00:00'), {
location: 'CAN.QUEBEC.MONTREAL'
})
);
// return true
// DST info for France (Paris)
console.log(
isDst(new Date('2019-11-28 21:00:00'), {
location: 'FRA'
})
);
// return false
```
## Implemented DST data
| Country | State | City | Key | Years |
| --------- | --------- | --------- | -------------------------- | --------- |
| Australia | Victoria | Melbourne | `AUS.VICTORIA.MELBOURNE` | 2000-2030 |
| Canada | Quebec | Montreal | `CAN.QUEBEC.MONTREAL` | 1980-2030 |
| | Ontario | Toronto | `CAN.ONTARIO.TORONTO` | 2000-2030 |
| France | Metropole | Paris | `FRA.METROPOLE.PARIS` | 2000-2030 |
| USA | HAWAI | | `USA.HAWAI` | all |
## How to participate
If you think something is missing or corrupted, please submit a PR to this repo!
### Some tools
- You have created your file and want to modify this README, use this tool (https://www.tablesgenerator.com/markdown_tables) to generate/modify the table.