Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
timezone-soft
Advanced tools
npm install timezone-soft
import soft from 'timezone-soft'
// get an IANA tz from user input
let timezones = soft('milwaukee')[0]
/*[{
iana: 'America/Chicago',
standard: { name: 'Central Standard Time', abbrev: 'CST' },
daylight: { name: 'Central Daylight Time', abbrev: 'CDT' }
}
]*/
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:
These names also collide -
'IST' is used to mean:
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.
const soft = require('timezone-soft')
soft('EST')
// 'America/New_York'
soft('central')
// 'America/Chicago'
soft('venezuela')
// 'America/Caracas'
soft('south east asia')
// 'Asia/Bangkok'
Typescript/Deno/Webpack:
import 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.
Often, the proper timezone name will depend on which date you are referencing. You can reckon this pretty-easily with spacetime, like this:
const spacetime = require('spacetime')
const soft = require('timezone-soft')
let display = soft('montreal')[0]
let show = display.standard.abbrev
// are we in standard time, or daylight time?
let s = spacetime.now(display.iana)
if (display.daylight && s.isDST()) {
show = display.daylight.abbrev
}
console.log(s.time() + ' ' + show)
// '4:20pm EDT'
work-in-progress!
MIT
FAQs
interpret abbreviated and informal timezone names
The npm package timezone-soft receives a total of 53,006 weekly downloads. As such, timezone-soft popularity was classified as popular.
We found that timezone-soft demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.