Installations
npm install timezone-soft
Releases
Unable to fetch releases
Developer
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
18.18.0
NPM Version
9.8.1
Statistics
27 Stars
144 Commits
6 Forks
3 Watching
3 Branches
8 Contributors
Updated on 24 Sept 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
4,430,328
Last day
-4.2%
12,675
Compared to previous day
Last week
-5%
58,807
Compared to previous week
Last month
9.7%
261,001
Compared to previous month
Last year
114.8%
2,501,728
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
npm install timezone-soft
1import soft from 'timezone-soft' 2 3// get an IANA tz from user input 4let timezones = soft('milwaukee')[0] 5/*[{ 6 iana: 'America/Chicago', 7 standard: { name: 'Central Standard Time', abbrev: 'CST' }, 8 daylight: { name: 'Central Daylight Time', abbrev: 'CDT' } 9 } 10]*/
IANA timezone codes are the official reference for timezone information, and is what you should use, whenever possible.
Humans though, are goofballs, and use a whole different informal scheme:
- In (North) America: PST, MST, EST...
- in Europe (lately): WEST, CEST, EEST...
- in Africa: EAT, CAT, WAST...
- in Australia: AWST, AEDT, ACST...
these line-up with the IANA codes sometimes.
...other times they don't.
These names also collide -
'IST' is used to mean:
- 'Indian Stardard Time'
- 'Irish Stardard Time'
- 'Israeli Stardard Time'
These names also produce all-sorts of ambiguities, regarding DST-changes-
Both Winnipeg and Mexico City are CST, but have a much different DST schedule:
(thanks timeanddate.com!)
-of course, there's a bunch of political/historical/disputed stuff going on, too. Apologies if this library steps into that unknowingly.
...so that's what we're trying to fix - to 'soften' this exchange, between human and IANA timezone nomenclature, using some opinionated-but-common-sense rules and decision-making.
It was originally built for use in the spacetime timezone library.
Usage
1const soft = require('timezone-soft') 2 3soft('EST') 4// 'America/New_York' 5 6soft('central') 7// 'America/Chicago' 8 9soft('venezuela') 10// 'America/Caracas' 11 12soft('south east asia') 13// 'Asia/Bangkok'
Typescript/Deno/Webpack:
1import soft from 'timezone-soft'
it was built to be as forgiving as possible, and return the most common-sense IANA timezone id from user-input.
DST
Often, the proper timezone name will depend on which date you are referencing. You can reckon this pretty-easily with spacetime, like this:
1const spacetime = require('spacetime') 2const soft = require('timezone-soft') 3 4let display = soft('montreal')[0] 5let show = display.standard.abbrev 6 7// are we in standard time, or daylight time? 8let s = spacetime.now(display.iana) 9if (display.daylight && s.isDST()) { 10 show = display.daylight.abbrev 11} 12console.log(s.time() + ' ' + show) 13// '4:20pm EDT'
work-in-progress!
See also
- TimeZoneNames .NET Standard Library by Matt Johnson-Pint
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
Reason
Found 3/7 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 28 are checked with a SAST tool
Score
2.9
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More