AngularJS features for TimezoneJS-enhanced JavaScript Date
objects.
This project will not receive additional features, bug fixes, or any other maintenance, and the project will be deleted on January 1, 2015. If you wish to continue development or work with more active projects where issues might be resolved, please see forks.
Bower users can add the following to their package dependencies. Be sure to see tags for a list of available versions.
{
"dependencies" : {
"angular-timezones" : "git@github.com:michaelahlers/angular-timezones.git#0.3.8"
}
}
After including angular-timezones.js
, add this package to your application.
var yourApplication = angular.module('your-application', ['Timezones'])
This package provides the IANA timezone data, but you may have this resource served from a different location or you wish to provide your own data. To change that location, set the $timezones.definitions.location
property to the appropriate path or URL.
yourApplication.constant('$timezones.definitions.location', '/custom/path/to/tz/data')
This is done by the unit tests and illustrated in docs/examples
.
The $timezones.resolve(timezone, reference)
function will, using the reference Date
provided, look up complete details about the timezone—including the abbreviation, offset, and decomposed region and locality. This is useful for avoiding clever tricks to extract abbreviations from Date.toString
(which is not particularly portable or robust). Additionally, resulting values are derived from the authoritative IANA timezone data.
If jsTimezoneDetect is included, the $timezones.getLocal()
function will detect the browser's local timezone and provide a complete definition that's resolved against the IANA database.
See docs/examples
for demonstrations of these features. As timezone data (found in tz/data
) must be served from a web server, these examples will not work from the local disk. However, there is a quick solution for most platforms: the files can be served with Python's SimpleHTTPServer
.
python -m SimpleHTTPServer
Once running, visit http://localhost:8000/
in your web browser, and navigate to the examples folder.
Timezones for Angular is tested with Karma and PhantomJS against the latest available release of jQuery (2.0.0) and AngularJS (1.1.4).
With NPM installed, you can test your modifications with the following.
npm install
npm test
This project was originally forked from angular-timezone-js
by Tomas Ruzicka.
Timezone data provided by IANA (extracted from tzdata2013c.tar.gz).