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

zoneinfo

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zoneinfo

Library to parse zoneinfo files for use with a wrapper around Date objects.

latest
Source
npmnpm
Version
0.1.8
Version published
Weekly downloads
73
5.8%
Maintainers
1
Weekly downloads
 
Created
Source

node-zoneinfo

Description

This is a project intened to provide zonefile-based timezone supporting Date objects.

Installation

You can install this through npm:

npm install zoneinfo

##Usage

An example of usage is as follows:

var sys = require('util');
var zoneinfo = require('zoneinfo'),
    TZDate = zoneinfo.TZDate,
    countrycodes = zoneinfo.countrycodes;

var d = new TZDate();
sys.puts(d);
//=> 2010-09-21 03:18:23 GMT
sys.puts(d.format("Y-m-d"));
//=> 2010-09-21
sys.puts(d.getTimezone());
//=> UTC
sys.puts(d.getTimezone(true));
//=> Etc/UTC
d.setTimezone("America/Denver");
sys.puts(d);
//=> 2010-09-20 21:18:23 GMT-0600
sys.puts(d.getTimezone());
//=> MDT
d.setTimezone("America/Los_Angeles");
sys.puts(d);
//=> 2010-09-20 20:18:23 GMT-0700
sys.puts(d.getTimezone());
//=> PDT
d.setTimezone("America/Phoenix");
sys.puts(d);
//=> 2010-09-20 20:18:23 GMT-0700
sys.puts(d.getTimezone());
//=> MST

zoneinfo.setDefaultTimezone("America/New_York");
var d = new TZDate("2010-11-08T16:00:00.000Z");
sys.puts(d);
//=> 2010-11-08 11:00:00 GMT-0500
sys.puts(d.getTimezone());
//=> EST
d.setTimezone("America/Denver");
sys.puts(d);
//=> 2010-11-08 09:00:00 GMT-0700
sys.puts(d.getTimezone());
//=> MST
d.setTimezone("America/Los_Angeles");
sys.puts(d);
//=> 2010-11-08 08:00:00 GMT-0800
sys.puts(d.getTimezone());
//=> PST
d.setTimezone("America/Phoenix");
sys.puts(d);
//=> 2010-11-08 09:00:00 GMT-0700
sys.puts(d.getTimezone());
//=> MST

sys.puts(sys.inspect(zoneinfo.listTimezones()));
//=> [array of all timezones on the system]
sys.puts(sys.inspect(zoneinfo.listTimezones("US")));
//=> [array of all US timezones on the system]

sys.puts(sys.inspect(countrycodes));
//=> [object of Name: Code pairs]

Tests

Tests that exist are written for Expresso (http://visionmedia.github.com/expresso/). To run them, install expresso and then run

expresso

Alternatively, you can run

expresso test/index.js

FAQs

Package last updated on 20 Feb 2013

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