Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
get-timezone-offset
Advanced tools
getTimezoneOffset is a tiny library ( less than 1k ) for getting timezone offsets.
It returns the timezone offset in minutes for any IANA timezone name for any date in the past, present and future.
It runs in any browsers or on the server, it's very small, very fast and has no dependencies1
var now = new Date();
getTimezoneOffset( 'America/New_York', now ); // returns 300
getTimezoneOffset( 'Antarctica/Davis', now ); // return -420
getTimezoneOffset is tiny and fast because it ships without a database of timezones, using the tz database of the underlying operating system via the global Intl
object.
Internationalization was introduced in 2012; Engine support is tracked here , but boils down to;
The tests will validate the library functionality and the javascript engine's implementation of Intl.DateTimeFormat
( and the operating systems tzinfo database ).
To test in node
npm test
To test in a browser
npm run test:browser
Then open test.html
in a browser and view the console output.
Results for locations that experience daylight saving change throughout the year Results for locations that [https://data.iana.org/time-zones/tzdb/NEWS](have moved timezone) may vary as the tz database is modified. This sometimes includes retrospective changes.
If you are running getTimezoneOffset on the server and using alpine or other ultra minimal docker image without a timezone database, you need to install the tzdata
package. Most docker images, including the "slim" images publishd by node already include tzdata
. ↩
FAQs
Tiny library to get timezone offsets for a place and time
The npm package get-timezone-offset receives a total of 2,548 weekly downloads. As such, get-timezone-offset popularity was classified as popular.
We found that get-timezone-offset 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.