Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timezoned-date

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timezoned-date

Constructors and objects behave exactly like built-in Date; the TZ offset is configurable

  • 3.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36K
decreased by-1.07%
Maintainers
1
Weekly downloads
 
Created
Source

timezoned-date Build Status npm

Constructors and objects behave exactly like built-in Date; the TZ offset is configurable

Tested against Test262 for the compatibility with Date.

No support for daylight saving time. Fixed offsets only.

Install

$ npm install --save timezoned-date

Usage

const timezonedDate = require('timezoned-date');
console.log(new Date());
// Sat Sep 19 2017 02:39:56 GMT+0300 (Ixania Daylight Time)
const UtcDate = timezonedDate.makeConstructor(0);
console.log(new UtcDate());
// Fri Sep 18 2017 23:39:56 GMT+0000 (UTC)
global.Date = timezonedDate.makeConstructor(240); // minutes
console.log(new Date());
// Sat Sep 19 2017 03:39:56 GMT+0400

An example of using it with jsdom:

const dom = new JSDOM(`<p>Hello</p>`, {
  beforeParse(window) {
    window.Date = timezonedDate.makeConstructor(240);
  }
});

API

makeConstructor(offsetInMinutes)

Returns a constructor function compatible with Date bound to the specified offset.

License

Apache 2.0 © 2013-2017 James A. Rosen, Georgii Dolzhykov

Keywords

FAQs

Package last updated on 19 May 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc