Giter Site home page Giter Site logo

ezic's Introduction

ezic

ezic is a native erlang library for working with timezones. It parses the Olson timezone database files, allowing native erlang timezone lookup and zone conversions without the use of shell commands or a UNIX system.

See the tz database page for more information about the Olson database.

Purpose

Erlang/OTP didn't have a native timezone library, so I wrote ezic to fill that void.

The recommended way of handling timezones in erlang involves setting the system environment variable TZ to the desired timezone, then calling erlang time functions. As far as I can tell, this technique has a few key issues:

  • it only works on *nix systems,
  • it depends on your system's timezone data (preventing custom timezone hackery), and
  • you can create race conditions if you aren't careful about it

ezic doesn't have these problems. ezic is, however, a young project with who-knows-how-many problems of its own.

API

  • ezic:localtime(TimeZone) -> datetime()
  • ezic:utc_to_local(universal_datetime(), TimeZone) -> local_datetime()
  • ezic:local_to_utc(local_datetime(), TimeZone) -> universal_datetime()

Example Setup

# setup your local environment
mkdir -p priv/tzdata

# download the timezone data files
wget 'ftp://ftp.iana.org/tz/tzdata-latest.tar.gz'
tar -xvzf tzdata-latest.tar.gz -C priv/tzdata

# remove a few troublesome files
cd priv/tzdata
rm *.sh *.gz *.tab factory Makefile

# build and run ezic
cd -
make all run
1> application:start(ezic).
2> ezic:localtime("Australia/Adelaide").

License

This project is in the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

Contributed Code

To maintain ezic's status as a public domain work, all contributions must also be dedicated to the public domain.

Acknowledgements

A big thanks to ezic's contributors:

The decision to release this into the public domain was inspired by the (anti-) license of the SQLite project.

ezic's People

Contributors

drfloob avatar amasyura avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.