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

timezone-mock

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timezone-mock

A JavaScript library to mock the local timezone.

  • 1.3.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
312K
decreased by-18.71%
Maintainers
1
Weekly downloads
 
Created

What is timezone-mock?

The 'timezone-mock' npm package allows developers to mock the system timezone in their Node.js applications. This is particularly useful for testing code that is sensitive to timezones without having to change the system timezone.

What are timezone-mock's main functionalities?

Mocking the System Timezone

This feature allows you to set a specific timezone for your Node.js application. The code sample demonstrates how to register the 'US/Pacific' timezone and then log the current date and time in that timezone.

const timezoneMock = require('timezone-mock');
timezoneMock.register('US/Pacific');
console.log(new Date().toString()); // Outputs date in US/Pacific timezone

Unregistering the Mocked Timezone

This feature allows you to unregister the mocked timezone and revert back to the system's default timezone. The code sample demonstrates how to unregister the 'US/Pacific' timezone and log the current date and time in the system's default timezone.

const timezoneMock = require('timezone-mock');
timezoneMock.register('US/Pacific');
console.log(new Date().toString()); // Outputs date in US/Pacific timezone
timezoneMock.unregister();
console.log(new Date().toString()); // Outputs date in the system's default timezone

Other packages similar to timezone-mock

Keywords

FAQs

Package last updated on 23 Jun 2022

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