timezone 1.1.2
Install from the command line:
Learn more about npm packages
$ npm install @wpmedia/timezone@1.1.2
Install via package.json:
"@wpmedia/timezone": "1.1.2"
About this version
ℹ️ NOTE: This is a published fork of the Timezone. The base library is no longer actively maintained. We noticed that the AM/PM meridians were not working for some locales and a fix wasn't accepted in time on the base repo. The fork is published to
@wpmedia/timezone
to GitHub Packages. The library was initially picked by a previous employee. Please see Setup below for more information around using GitHub Packages.
Format time in JavaScript using the IANA time zone database.
var tz = require("@wpmedia/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 GNUdate
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.
Note the git submodule update --init --recursive
command to initialize the submodules that sources some of the information. For more about submodules, see Submodules.
$ git clone --quiet https://github.com/WPMedia/timezone
$ cd timezone
$ git submodule update --init --recursive
$ make && npm i && npm t
First, need to update the output in build folder via make
and the Makefile
. Then the test will be ran based on that update.
$ make
$ npm t
Make sure you have an .npmrc
that is sso-enabled and allows for updating GitHub Packages.
@wpmedia:registry=https://npm.pkg.github.com/
registry=https://registry.npmjs.org
//npm.pkg.github.com/:_authToken={token generated from github}
We want to publish the package with a flattened folder structure. So it's needed to run npm publish @wpmedia/timezone
. After any change is made to the package.json, the make
command needs to run to update the build folder's package.json
within build/timezone/package.json
.
To test what will be included in the npm publish, it's helpful to run npm publish @wpmedia/timezone --dry-run
to see what will be published.
$ make
$ npm publish build/timezone
Includes @wpmedia/timezone/locales
and @wpmedia/zones
. Also includes the default library of utils for @wpmedia/timezone
. This is a large import and should be used with caution.
The default import at the index. This includes date utils for converting to and from POSIX time and RFC 3999 date strings.
This can not be cleaned on post-install or else core functionality will be affected.
The default import at the zones. This has location-specific information around regions and countries, such as US. Locales is also included in this import.
Includes all potential locales, such as af_ZA.js
. This is a large import and should be used with caution. These locales include month names and default formatting.
This can be cleaned on post-install to only include the required locales.
If all of the tests do not pass, please make sure you have the latest version of the submodules. See Setup above for more information git submodule update --init --recursive
.
The MIT License.