New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@smhg/date-time-zone

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smhg/date-time-zone

Create and manipulate time zone specific dates as regular Date objects.

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
10
42.86%
Maintainers
1
Weekly downloads
 
Created
Source

date-time-zone Build status

Create and manipulate time zone specific dates as regular Date objects. (Abuses)Uses Intl and Proxy.

Example

const { createDate, detectTimeZone } = require('@smhg/date-time-zone');

if (!detectTimeZone()) {
  console.warn('Time zones not (fully) supported');
}

const timeZone = 'Europe/Berlin';
createDate({ timeZone }); // now

createDate(2019, 0, 1, { timeZone }); // start of 2019 in Berlin

const date = createDate({ timeZone });
date.setHours(0, 0, 0, 0);
console.log(date.toString()); // start of today in Berlin

Usage

When you need to work with a Date instance in another time zone, replace new Date with createDate and add an options object ({ timeZone: '...' }) as the last parameter.

All other usage is the same as regular Date objects, with manipulations (setDate, setHours, ...) happening in the specified time zone and toString() returning the date and time in the specified time zone.

FAQs

Package last updated on 26 Jul 2019

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