Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@vvo/tzdb
Advanced tools
Simplified, grouped and always up to date list of time zones, with major cities
@vvo/tzdb is an npm package that provides a comprehensive database of time zones. It allows developers to easily access and manipulate time zone data, including retrieving time zone names, offsets, and other related information.
Get all time zones
This feature allows you to retrieve a list of all available time zones. The code sample demonstrates how to use the `getTimeZones` function to get an array of time zone objects.
const { getTimeZones } = require('@vvo/tzdb');
const timeZones = getTimeZones();
console.log(timeZones);
Get time zone by name
This feature allows you to retrieve detailed information about a specific time zone by its name. The code sample shows how to use the `getTimeZone` function to get details for the 'America/New_York' time zone.
const { getTimeZone } = require('@vvo/tzdb');
const timeZone = getTimeZone('America/New_York');
console.log(timeZone);
Get time zone offset
This feature allows you to get the offset of a specific time zone. The code sample demonstrates how to use the `getTimeZoneOffset` function to get the offset for the 'America/New_York' time zone.
const { getTimeZoneOffset } = require('@vvo/tzdb');
const offset = getTimeZoneOffset('America/New_York');
console.log(offset);
Moment-timezone is a popular package that extends the Moment.js library to handle time zones. It provides similar functionalities to @vvo/tzdb, such as retrieving time zone data and converting between time zones. However, it is built on top of Moment.js, which can be heavier and more complex compared to @vvo/tzdb.
Luxon is a modern JavaScript library for working with dates and times. It includes built-in support for time zones and offers a more modern API compared to Moment.js. Luxon provides similar functionalities to @vvo/tzdb but also includes additional features for date and time manipulation.
Date-fns-tz is an extension of the date-fns library that adds support for time zones. It provides functions to convert dates between time zones and to get time zone offsets. Date-fns-tz offers a lightweight and functional approach to handling time zones, similar to @vvo/tzdb.
This is a list and npm package of:
Pacific Time
instead of America/Los_Angeles
, along with major cities for each time zone.The data and npm packages are automatically updated whenever there are changes to https://www.geonames.org/ which is generated from IANA databases.
This is useful whenever you want to build a time zone select menu in your application.
This is most probably what you're looking for if you're trying to build a good current time zones selector in your application.
Example data:
[
// ...
{
name: "America/Anchorage",
alternativeName: "Alaska Time",
mainCities: ["Anchorage", "Juneau"],
formatted: "-09:00 Alaska Time - Anchorage, Juneau",
group: [
"America/Anchorage",
"America/Juneau",
"America/Metlakatla",
"America/Nome",
"America/Sitka",
"America/Yakutat",
],
},
{
name: "Pacific/Gambier",
alternativeName: "Gambier Time",
mainCities: ["Gambier"],
formatted: "-09:00 Gambier Time - Gambier",
group: ["Pacific/Gambier"],
},
{
name: "America/Los_Angeles",
alternativeName: "Pacific Time",
mainCities: ["Los Angeles", "San Diego"],
formatted: "-08:00 Pacific Time - Los Angeles, San Diego",
group: ["America/Los_Angeles"],
},
// ...
];
As you can see, we provide the time zone name and a pre-formatted version using more common offset names.
Notes:
This is the raw list of all IANA time zones ranked by alphabetical order.
Example data:
[
// ...
"America/La_Paz",
"America/Lima",
"America/Los_Angeles",
"America/Lower_Princes",
"America/Maceio",
"America/Managua",
"America/Manaus",
"America/Marigot",
"America/Martinique",
// ...
];
Installation:
npm add @vvo/tzdb
Usage:
import timeZones from "@vvo/tzdb/time-zones-names.json";
import simplifiedTimeZones from "@vvo/tzdb/simplified-time-zones.json";
You can store cities information on a search engine like Algolia. There's a yarn build
command you can use if you clone this repository to create your own Algolia index. The expected environment variables are:
ALGOLIA_APPLICATION_ID=... ALGOLIA_ADMIN_API_KEY=... ALGOLIA_INDEX_NAME=... yarn build
Here's a demo of the index:
FAQs
Always up to date list of time zones, with grouping and major cities
The npm package @vvo/tzdb receives a total of 108,018 weekly downloads. As such, @vvo/tzdb popularity was classified as popular.
We found that @vvo/tzdb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.