New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ebx-timezone-mock

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ebx-timezone-mock

A JavaScript library which mocks the Date object and lets you specify a local date/time/timezone in order to enable consistent testing of date/time-related code independently of your local system time settings.

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
decreased by-87.11%
Maintainers
1
Weekly downloads
 
Created
Source

ebx-timezone-mock

A JavaScript library which mocks the Date object and lets you specify a local date/time/timezone in order to enable consistent testing of date/time-related code independently of your local system time settings.

It works by monkey patching the Date object and returning results which are adjusted to reflect the effects of both the specified current date/time/timezone (if any) and the current date/time/timezone. In particular, it avoids problems caused by certain JavaScript date/time methods e.g. getHours returning results in the user's local system time, so you can write date/time-related unit tests which will work whenever and wherever they are run, without changing timezones causing results to change.

Installation

NPM

$ npm install ebx-timezone-mock

Usage

Configuration

import TimezoneMock from 'TimezoneMock';

TimezoneMock.set('2018-04-25T12:34:56.000Z');

console.log(new Date()); // Wed Apr 25 2018 12:34:56 GMT+0000 (GMT Standard Time)

TimezoneMock.reset();

console.log(new Date()); // Current system date/time/timezone

Credits

The majority of the code for this project was taken from the timezone-mock project by Jimb Esser, with some additional code from the MockDate project by Bob Lauer. My contribution has been limited to gluing these two projects together, and introduction moment-timezone to solve the problem of working out the timezone offset for any given date, time and place.

Keywords

FAQs

Package last updated on 15 May 2018

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