
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
timezone-groups
Advanced tools
A JavaScript library to group time zones based on offset (DST-aware), name or region.
timezone-groups
is a versatile NPM package that allows you to effortlessly generate timezone groups in both Node.js and browser environments. It supports multiple date libraries, including the option to create and use custom ones.
Install the package via NPM using the following command:
npm install timezone-groups
groupByOffset
import { groupByOffset } from "timezone-groups/groupByOffset";
import { DateEngine } from "timezone-groups/groupByOffset/strategy/native";
const timeZoneGroups = await groupByOffset({
startDate, // The start reference date to generate the groups (defaults to now).
groupDateRange, // The number of days to consider for the DST groupings (defaults to 365).
dateEngine: new DateEngine(), // The date engine instance used to generate groups. You can use the `createDateEngine` utility to create an engine from any of the supported engine values. Alternatively, a custom date engine instance used to generate groups.
});
console.log(timeZoneGroups);
// Output:
// [
// {
// "labelIdx": [0, ..., 46],
// "tzs": ["America/Anguilla", ..., "America/Tortola"]
// },
// ...
// ]
groupByName
import { groupByName } from "timezone-groups/groupByName";
const timeZoneGroups = await groupByName();
console.log(timeZoneGroups);
// Output:
// [
// {
// "label": "Africa/Abidjan",
// },
// {
// "label": "Africa/Accra",
// },
// ...
// ]
groupByRegion
import { groupByRegion } from "timezone-groups/groupByRegion";
const timeZoneGroups = await groupByRegion();
console.log(timeZoneGroups);
// Output:
// [
// {
// "label": "Africa",
// "tzs": ["Africa/Abidjan", ..., "Africa/Windhoek"]
// },
// {
// "label": "America",
// "tzs": ["America/Adak", ..., "America/Yakutat"]
// },
// ...
// ]
Intl.supportedValuesOf("timeZone")
.FAQs
A JavaScript library to group time zones based on offset (DST-aware), name or region.
The npm package timezone-groups receives a total of 53,498 weekly downloads. As such, timezone-groups popularity was classified as popular.
We found that timezone-groups 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.