Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
timezone-support
Advanced tools
Readme
Lightweight time zone listing and date converting. Intended for adding time zone support to high-level date libraries, but also for direct application usage.
Attention: exported identifiers in vanilla browser modules changed in the version 2.0.0. See the migration guide for more information.
const {
listTimeZones, findTimeZone, getZonedTime, getUnixTime
} = require('timezone-support')
// List canonical time zone names: [ 'Africa/Abidjan', ... ]
const timeZones = listTimeZones()
// Find a particular time zone: { name: 'Europe/Berlin', ... }
const berlin = findTimeZone('Europe/Berlin')
// Convert a date to a specific time zone: { year, month, day, dayOfWeek,
// hours, minutes, seconds, milliseconds, epoch, zone: { abbreviation, offset } }
const nativeDate = new Date()
const berlinTime = getZonedTime(nativeDate, berlin)
// Convert a time from a specific time zone: native Date object
const berlinTime = { year: 2018, month: 9, day: 2, hours: 10, minutes: 0 }
const nativeDate = new Date(getUnixTime(berlinTime, berlin))
This module can be installed in your project using NPM, PNPM or Yarn. Make sure, that you use Node.js version 14.8 or newer.
$ npm i timezone-support
$ pnpm i timezone-support
$ yarn add timezone-support
Functions are exposed as named exports from the package modules, for example:
const { findTimeZone, getZonedTime } = require('timezone-support')
You can read more about the module loading in other environments, like with ES6 or in web browsers. Usage scenarios demonstrate applications of this library in typical real-world scenarios. Design concepts explain the approach to time zone handling taken by tni library and types of values used ion the interface. Generating custom time zone data will allow you to save the overall package size by limiting the supported year span. Finally, the API reference lists all functions with a description of their functionality.
You can see complete sample applications too, which can help you start with integration of this library.
Date
object.In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Copyright (c) 2018-2022 Ferdinand Prantl
Licensed under the MIT license.
FAQs
Lightweight time zone support for your applications or other date libraries.
The npm package timezone-support receives a total of 148,337 weekly downloads. As such, timezone-support popularity was classified as popular.
We found that timezone-support 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.