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

timezone-date.ts

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timezone-date.ts

Enhancement of Date class with better timezone support

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
99
increased by73.68%
Maintainers
1
Weekly downloads
 
Created
Source

timezone-date.ts

Enhancement of Date class with better timezone support.

npm Package Version

Features

  • Compliant to Date methods
  • Allow changing timezone anytime
  • Typescript support
  • Tiny code base - 3.8KB minified

Example

import { TimezoneDate } from 'timezone-date.ts'

const d = TimezoneDate.fromDate(new Date('2020-04-21T10:00:00.000Z'))

d.timezone = 0
d.getHours() // 10

d.timezone = +8
d.getHours() // 18

d.getTimezoneOffset() // -480 (in mintes, same format as Native Date)

d.setHours(9)
d.timezone++
d.getHours() // 10
d.toLocaleTimeString() // '10:00:00 AM'

Installation

npm i timezone-date.ts

Construction

import { TimezoneDate } from 'timezone-date.ts'

/* custom timezone */
new TimezoneDate(Date.now(), {timezone: +8})

/* default timezone (in the environment) */
new TimezoneDate()                 // current time
new TimezoneDate(Date.now())
TimezoneDate.fromTime(Date.now())
TimezoneDate.fromDate(new Date())
TimezoneDate.from(Date.now())      // from Date or timestamp

License

This is free open sourced software (FOSS), with BSD 2-Clause License

Keywords

FAQs

Package last updated on 24 Apr 2020

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