Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
mock-browser-timezone
Advanced tools
A Javascript library to mock the browser's timezone using ECMAScript Internationalization API.
A Javascript library to mock the browser's timezone using ECMAScript Internationalization API.
Many modern browsers use the Intl API to get the desired IANA timezone string which depicts the current browser timezone.
This library is specifically designed to mock the browser timezone, assisting to test the relevant code which uses the Intl
API.
npm install mock-browser-timezone --save-dev
yarn add mock-browser-timezone -D
For a better implementation of mock-browser-timezone
, have a look at mock-browser-timezone.js
file.
const {
registerTimezone,
registerAbbreviatedTimezone,
reset,
} = require('mock-browser-timezone');
// Mocking the timezone using IANA timezone string.
registerTimezone('Europe/Paris');
reset(); // Default back to the orginal value.
new Intl.DateTimeFormat().resolvedOptions().timeZone; // Europe/Paris
registerAbbreviatedTimezone('CET');
new Intl.DateTimeFormat([], {
timeZoneName: 'short',
})
.formatToParts(date)
.find((locale) => locale.type === 'timeZoneName').value; // CET
reset(); // Default back to the orginal abbreviated timezone value.
A list of supported IANA formatted timezones as well as abbreviated timezones can be found at timezones.json
.
FAQs
A Javascript library to mock the browser's timezone using ECMAScript Internationalization API.
The npm package mock-browser-timezone receives a total of 22 weekly downloads. As such, mock-browser-timezone popularity was classified as not popular.
We found that mock-browser-timezone demonstrated a not healthy version release cadence and project activity because the last version was released 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
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.