Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

timezone

bigeasy115.4kMIT1.0.23

Small, elegant, Olson educated, timezone aware date math and strftime date formatting in pure JavaScript with no dependendcies for Node.js and the browser. Timezone uses the Olson/IANA timezone database. Timezone is aware of every clock transition in th

time, timezone, date, clock, wall-clock, tzdata, utc, gmt, datetime, tz, format, events, calendar, strftime

readme

Sundial

Timezone Build Status

Format time in JavaScript using the IANA time zone database. (Photo: Sundial by Wolfgang Staudt.)

var tz = require('timezone/loaded'),
    equal = require('assert').equal,
    utc;

// Get POSIX time in UTC.
utc = tz('2012-01-01');

// Convert UTC time to local time in a localize language.
equal(tz(utc, '%c', 'fr_FR', 'America/Montreal'),
      'sam. 31 déc. 2011 19:00:00 EST');

A full-featured time zone aware date formatter for JavaScript.

  • Timezone is a MicroJS library in pure JavaScript with no dependencies that provides timezone aware date math and date formatting.
  • Timezone uses the IANA Database to determine the correct wall clock time anywhere in the world for any time since the dawn of standardized time.
  • Timezone formats dates with a full implementation of strftime formats, including the GNU date extensions.
  • Timezone represents time in POSIX time and local time using RFC 3999 date strings.
  • Timezone is a full featured standards based time library in pure JavaScript for under 3K minified and gzipped.

Hacking

$ git clone --quiet https://github.com/bigeasy/timezone.git
$ cd timezone && make && npm install && npm test

License

The MIT License.

changelog

  • Version 1.0.23.

Sat Nov 30 20:40:10 UTC 2019

  • Build with Node.js 12 on Travis CI. #324.
  • Upgrade IANA TZ Database for 2019a. #323.
  • Version 1.0.22.

Thu Jan 24 08:32:11 UTC 2019

  • Upgrade IANA TZ Database for 2018i. #316.
  • Version 1.0.21.

Tue Jan 22 14:05:55 UTC 2019

  • Upgrade IANA TZ Database for 2018h. #314.
  • Version 1.0.20.

Wed Oct 31 12:38:57 UTC 2018

  • Upgrade IANA TZ Database for 2018g. #311.
  • Version 1.0.19.

Wed Oct 31 09:06:38 UTC 2018

  • Upgrade IANA TZ Database for 2018f. #309.
  • Version 1.0.18.

Fri Oct 5 07:15:16 UTC 2018

  • Upgrade IANA TZ Database for 2018e. #302.
  • Allow negative time zone offset in Rules column. #307.
  • Version 1.0.17.

Thu Oct 4 09:06:00 UTC 2018

  • Use shorthand URL in package.json. #305.
  • Upgrade IANA TZ Database for 2018d. #301.
  • Version 1.0.16.

Wed Oct 3 16:26:12 UTC 2018

  • Upgrade IANA TZ Database for 2018c. Closes #300.
  • Tidy commit messages in checklist utility. Closes #303.
  • Version 1.0.15.

Wed Oct 3 09:20:37 UTC 2018

  • Remove dimensions from README.md image. #299.
  • Upgrade IANA TZ Database for 2018b. #297.
  • Version 1.0.14.

Tue Oct 2 06:39:47 UTC 2018

  • Build with Node.js 10 on Travis CI. #296.
  • Remove zdump.patch. #295.
  • Upgrade IANA TZ Database for 2018a. #293.
  • Version 1.0.13.

Sun Nov 19 10:01:52 UTC 2017

  • Upgrade IANA TZ Database for 2017c. #290.
  • Version 1.0.12.

Sun Nov 19 09:10:40 UTC 2017

  • Upgrade IANA TZ Database for 2017b. #288.
  • Version 1.0.11.

Sun Nov 19 08:37:40 UTC 2017

  • Upgrade IANA TZ Database for 2017a. #286.
  • Version 1.0.10.

Sun Nov 19 03:55:44 UTC 2017

  • Upgrade IANA TZ Database for 2016j. #284.
  • Version 1.0.9.

Fri Nov 17 15:53:07 UTC 2017

  • Upgrade IANA TZ Database for 2016i. #282.
  • Version 1.0.8.

Fri Nov 17 14:54:24 UTC 2017

  • Upgrade IANA TZ Database for 2016h. #280.
  • Version 1.0.7.

Fri Nov 17 07:50:56 UTC 2017

  • Upgrade IANA TZ Database to 2016g. #278.
  • Do not change input date array. #276.
  • Version 1.0.6.

Wed Jul 13 16:22:50 UTC 2016

  • Upgrade IANA TZ Database to 2016f. #275.
  • Version 1.0.5.

Wed Jun 15 16:30:23 UTC 2016

  • Upgrade IANA TZ Database to 2016e. #272.
  • Version 1.0.4.

Thu Jun 9 02:36:10 UTC 2016

  • Upgrade IANA TZ Database to 2016d. #266.
  • Version 1.0.3.

Thu Jun 9 02:11:50 UTC 2016

  • Upgrade IANA TZ Database to 2016c. #269.
  • Version 1.0.2.

Thu Jun 9 01:26:34 UTC 2016

  • Upgrade IANA TZ Database to 2016b. #267.
  • Version 1.0.1.

Tue Feb 16 16:13:47 UTC 2016

  • Upgrade IANA TZ Database to 2016a. #264.
  • Version 1.0.0.

Mon Feb 15 20:58:45 UTC 2016

  • Decide that the API is finished.
  • Version 0.0.48.

Sun Nov 29 20:29:46 UTC 2015

  • Test with Node.js 5.1 on Travis CI. f5d44667b81356e3f8ea43e2cd682add7d8b39b2.
  • Test with Node.js 4.2 on Travis CI. c56d3e2fc43eb1d2475187de103de7aa4f4042b0.
  • Use require for resource indexes. #259.
  • Continued test tidy. #244.
  • Version 0.0.47.

Thu Oct 8 00:03:03 UTC 2015

  • Upgrade IANA TZ Database to 2015g. #257.
  • More testing tidy.
  • Version 0.0.46.

Tue Sep 29 02:29:26 UTC 2015

  • Upgrade TZ Database to tz2015f. #255.
  • Version 0.0.45.

Sun Sep 27 04:26:41 UTC 2015

  • Upgrade TZ Database to tz2015e. #253.
  • Version 0.0.44.

Sat Sep 26 04:58:12 UTC 2015

  • Upgrade TZ Database to tz2015d. #248.
  • Version 0.0.43.

Thu Sep 24 04:40:30 UTC 2015

  • Publish over damaged version 0.0.42 in NPM.
  • Version 0.0.42.

Tue Sep 22 06:26:55 UTC 2015

  • Upgrade TZ Database to tz2015c. #234.
  • Version 0.0.41.

Fri Apr 17 07:45:24 UTC 2015

  • Upgrade TZ Database to tz2015b. #232.
  • Version 0.0.40.

Fri Feb 6 14:40:10 UTC 2015

  • Upgrade TZ Database to tz2015a. #230.
  • Version 0.0.39.

Fri Feb 6 13:23:08 UTC 2015

  • Upgrade TZ Database to tz2014j. #227.
  • Version 0.0.38.

Mon Nov 3 13:40:31 UTC 2014

  • Cannot find module timezone/loaded. #223.
  • Version 0.0.37.

Thu Oct 30 23:24:49 UTC 2014

  • Upgrade TZ Database to tz2014i. #221.
  • Version 0.0.36.

Thu Oct 30 22:31:20 UTC 2014

  • Upgrade TZ Database to tz2014h. #218.
  • Version 0.0.35.

Sun Oct 26 03:17:59 UTC 2014

  • Upgrade TZ Database to tz2014g. #217.
  • Version 0.0.34.

Thu Aug 7 01:55:45 UTC 2014

  • Upgrade TZ Database to tz2014f. #215.
  • Version 0.0.33.

Fri Jun 27 16:21:08 UTC 2014

  • Upgrade TZ Database to tz2014e. #213.
  • Version 0.0.32.

Mon Jun 2 06:34:24 UTC 2014

  • Upgrade TZ Database to tz2014d. #211.
  • Version 0.0.31.

Sun Jun 1 21:14:47 UTC 2014

  • Upgrade TZ database to 2014b. #209.
  • Upgrade Proof to 0.0.45. #208.
  • Version 0.0.30.

Fri Mar 28 02:32:38 UTC 2014

  • Upgrade TZ database to 2014b. #206.
  • Upgrade Proof to 0.0.44. #205.
  • Version 0.0.29.

Sun Mar 16 04:47:13 UTC 2014

  • Upgrade to 2014a. #202.
  • Version 0.0.28.

Wed Feb 12 18:53:25 UTC 2014

  • Upgrade TZ library to 2013i. #200.
  • Version 0.0.27.

Wed Feb 12 16:49:07 UTC 2014

  • Upgrade TZ database to 2013h. #198.
  • Add punctuation to checklist. #197.
  • Version 0.0.26.

Wed Feb 12 03:44:56 UTC 2014

  • Upgrade TZ database to 2013g. #195.
  • Version 0.0.25.

Tue Feb 11 00:08:41 UTC 2014

  • Upgrade TZ database to tz2013f. #193.
  • Add missing pushes to checklist. #192.
  • Update checklist with one liners. #191.
  • Version 0.0.24.

Sat Feb 8 08:44:49 UTC 2014

  • Upgrade TZ database to tz2013e. #189.
  • Remove "url" property from package.json. #188.
  • Upgrade Proof to 0.0.42. #187.
  • Fix homepage in package.json. #186.
  • Add license property to package.json. #185.
  • Remove Node 0.6 target from Travis CI. #184.
  • Add repository type to package.json. #183.
  • Tidy package.json. #182.
  • Create a checklist utility. #181.
  • Add bugs property to package.json. #179.
  • Version 0.0.23.

Fri Aug 2 00:17:59 UTC 2013

  • Upgrade Proof to 0.0.33. #177.
  • Fix mass resource loading for Node.js on Windows. #176.
  • Version 0.0.22.

Fri Jul 12 04:36:22 UTC 2013

  • Update timezone database to tz2013d. #166.
  • Upgrade Proof to 0.0.32. #168.
  • Version 0.0.21.

Mon May 20 16:45:16 UTC 2013

  • Update timezone database to tz2013c. #156.
  • Version 0.0.20.

Thu May 16 00:00:56 UTC 2013

  • Add Eero Ränik to contributors.
  • Include time zone links wish slashes in their names.
  • Fix bogus limit on TZ rules. #158.
  • Build Etc zones. #147.
  • Version 0.0.19.

Thu Mar 14 00:03:08 UTC 2013

  • Update timezone database to tz2013b. #142.
  • Version 0.0.18.

Wed Mar 6 19:48:32 UTC 2013

  • Added make publish target to Makefile. #141.
  • Release to fix broken NPM publish. #140.
  • Version 0.0.17.

Wed Mar 6 07:21:33 UTC 2013

  • Update timezone database to tz2013a.
  • Version 0.0.16

Wed Jan 2 04:12:59 UTC 2013

  • Fix typo in README.md example. #128.
  • Fix synopsis.js Polish format example. #122.
  • Set eggert/tz to tzdata2012j release. #132.
  • Organize project directory as a compiled project. #135.
  • Multiple targets to simplify Makefile. #130.
  • Added .js suffix to unit tests. #133.
  • Use eggert/tz GitHub repo as database source. #134.
  • Added a picture to the README.md. #121.
  • Version 0.0.15 - Wed Jul 18 20:40:46 UTC 2012

    • Created a Markdown README.md. #118. #115.
    • Added many locales. #116.
    • Upgraded to Proof 0.0.15. #117. #113. #105. #102. #101.
    • Removed main property from package.json. #104.
    • Tidy whitespace and semi-colons. #97.
    • Plug all leaks of names into the global namespace. #107.
    • Run utility/sizes at Travis CI as part of continuous intgration build.

      103.

    • Added typeof test against module in module loader preamble to timezones.js and rfc822.js. #94.
    • Merge applicable function into find. #95.
    • Merge format function into convert. #91.
    • Call applicable once. #88.
    • Merge parse function into convert. #87.
    • Merge parseAdjustment function into convert. #86.
    • Remove slice of arguments in convert. #93.
    • Delete fields variable from actualize. #92.
    • Merge make function into convert. #85.
    • Build on Node.js 0.8, add 0.8 to Travis CI. #90.
    • Fixed synopsis.js assertions. #89.
  • Version 0.0.14 - Mon Jun 25 21:02:24 UTC 2012

    • Publish tarball of data files at GitHub. #55.
    • Created AMD, JSONP and JSON files hosted at GitHub:Pages for use in web applications. #23.
    • Spell check README. #61.
    • Remove used data file from test directories. #67.
    • Make zic at Travis CI. #82.
    • Minify with lifted variables. #79.
    • Test minified code at Travis CI. #78.
    • Create loaded.js module to create a pre-loaded Timezone function. #42.
    • Simplify module loading boilerplate. #76.
    • Document date array and time zone format specifiers in synopsis.js. #50.
    • Remove milli synonym for millisecond math unit. #66.
    • Remove cached Array.push variable. #75.
    • Bump version string returned by Timezone function. #77. #72.
    • Reorganize actualize for byte savings. #63.
    • Revert to one based month in date array. #74.
    • Exclude non-JavaScript files, crufty files, from slurp.js indices. #71.
    • Remove over-zealous, bloaty argument verification. #70.
  • Version 0.0.13 - Mon Jun 25 11:05:06 UTC 2012

    • Return internal state using function argument. #57.
    • Return library version when called with no arguments. #54.
    • Remove posix local variable from convert to save bytes. #62.
    • Add "@" to start of date array.
    • Add "z" to time zone data file array to differentiate zone entries from daylight savings time rules.
  • Version 0.0.12 - Sun Jun 24 04:40:41 UTC 2012

    • Clean up commented out code. #65.
    • Retry unknown string arguments after all data sets are loaded. #59.
    • Remove parseInt to save bytes. #58.
    • Make format a non-member function to save bytes. #60.
    • Implement external RFC 822 parser function. #56.
    • Date arrays now fixed length. #52.
    • Replace ternary operator with short circuit or to save bytes. #53.
    • Reorder lexically similar code for better minification. #44.
    • Remove comparisons to zero to save bytes. #45.
    • UTC with partial didn't work if partial specified time zone name. #51.
    • Removed TODOs. #46.
    • Removed require.date property to save bytes. #47.
    • Accept numeric object for POSIX time. #48.
    • Build on OS X. #31.
    • Deleted defunct index.js. #49.
    • No longer parsing time only date strings. #30.
    • Implement %^z. #28.
    • Correctly format %z in UTC. #43.
    • Implement UK English, French and German locales. #26.
    • Convert Proof tests to JavaScript. #36.
    • Timezone zones and locales in package root. #34. #33.
    • Updates and revisions to synopsis.js.
  • Version 0.0.11 - Thu Jun 14 18:04:39 UTC 2012

    • Correctly format %_:z. #40.
    • Correctly format %-:z. #39.
    • Tidy and sort out change log. #38.
    • Minor changes to save a few bytes when minified and zipped.
    • Accept Date as date argument.
    • Convert to plain text README. #37.
    • Combine timezone.js with date.js. #35. #25.
  • Version 0.0.10 - Mon May 21 18:52:31 UTC 2012

    • Draft synopsis.js.
    • Remove CoffeeScript source. #27.
    • Correctly apply parsed timezone offset. #24.
    • Use specified padding GNU strftime extension. #22.
    • Implement linked zone files as copies. #11.
    • Replace binary search with skip-list search. #21.
    • Add heuristics assertions to pre-compiler. #16.
    • Use Ruby 1.9.3 to verify %::z formats using tzdata files.
    • Convert pre-compiler and library to CoffeeScript.
    • Add tests against tzdata to npm test. #17.
    • GNU strftime format parity. #9. #19.
    • Fixed %C which was off by machine zone offset.
    • Implemented parse RFC 3999 without year. #3. #7.
    • Added support for RequireJS AMD.
    • Changes to week of year functions for size savings. #20.
    • tz function is now the sole export of Timezone.
    • Accept date as an array of date fields.
    • Split less commonly used GNU date formats out into date.js.
    • Use Object.create to when creating partial tz functions.
    • Limit date parsing to RFC 3999.
    • Reject Date as date argument.
  • Version 0.0.9 - Wed Apr 25 22:07:44 UTC 2012

    • Create README.md from timezone.idl. .idl is a document format for a document generator that I'm never going to write.
    • Move grumbling from README.md to MOTIVATIONS.md.
    • Add milliseconds as a synonym for millis to date math.
    • Configuration via partial functions.
    • Fix subtraction of years as per #10.
    • Attempt to create JSON as Olson by parsing the Olson files backwards in time.
    • Convert intermediate interval boundaries format to start time from end time.
    • Interpret slash delimited timezone abbreviations.
    • Interpret zone records with a specific savings offset.
    • Correctly convert between standard, wall-clock and POSIX time in preprocessing.
    • Correctly interpret rules that occur at the 24th hour; 24:00.
    • Correctly format %Z.
    • Use binary search against a generated table of rules.
    • Organize precompiler into a library and separate programs.
    • Create experimental 7-bit encoding and push it to the sidelines.
    • Redo intermediate zone file format, create clock property, offset in POSIX time.
    • Use Date to calculate last day of month.
    • Parse Olson files going forward in time, not backwards.
    • Remove generated timezone files from git.
    • Automate download of Olson file source, compilation of of zic, and Olson as JSON files.
    • Build zic at Travis CI for testing.
    • Remove locale aware date parsing. (NLP is out of scope.)
    • Parse New Year's 1970. (Was confused over 0 and undefined.)
    • Calculate timezone lookup table to 2037.
  • Version 0.0.8 - Sun Mar 18 00:42:46 UTC 2012

    • Add tz.now date parameter.
    • Fix month subtraction.
    • Convert tests to Proof.
  • Version 0.0.7 - Thu Oct 20 23:54:43 UTC 2011

    • Date math using day of week; i.e. move forward two Fridays.
    • Polish locale.
    • Tests for US and Polish locales.
  • Version 0.0.6 - Fri Oct 14 09:27:42 UTC 2011

    • Install from NPM with a set of available timezones.