updated the readme. error-tested the local_to_utc methods. light changes to the makefile
This commit is contained in:
11
Makefile
11
Makefile
@@ -5,7 +5,7 @@ DEBUG := -DNODEBUG -Ddebug
|
|||||||
TEST :=
|
TEST :=
|
||||||
TZSET := northamerica
|
TZSET := northamerica
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
COMPILE := ./src/*.erl
|
||||||
|
|
||||||
all : clean compile
|
all : clean compile
|
||||||
|
|
||||||
@@ -16,12 +16,13 @@ nowarn : clean compile
|
|||||||
|
|
||||||
test : ERLC_WARNINGS := -W0
|
test : ERLC_WARNINGS := -W0
|
||||||
test : TEST := -DTEST
|
test : TEST := -DTEST
|
||||||
test : all
|
test : RUN_INIT += -run test all -s erlang halt
|
||||||
erlc $(ERLC_WARNINGS) $(TEST) -o ./ebin ./test/*.erl
|
test : COMPILE += ./test/*.erl
|
||||||
erl -noshell -pa ebin -run test all -s erlang halt
|
test : all run
|
||||||
|
|
||||||
|
|
||||||
compile :
|
compile :
|
||||||
erlc $(DEBUG) $(TEST) $(ERLC_WARNINGS) $(OPTIONS) -o ./ebin ./src/*.erl
|
erlc $(DEBUG) $(TEST) $(ERLC_WARNINGS) $(OPTIONS) -o ./ebin $(COMPILE)
|
||||||
-erl -noshell -pa ebin -s erldev make_app . -s erlang halt
|
-erl -noshell -pa ebin -s erldev make_app . -s erlang halt
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -1,12 +1,16 @@
|
|||||||
ezic
|
ezic
|
||||||
====
|
====
|
||||||
ezic is a set of erlang utilities for the Olson timezone database files. See the [tz database](http://www.twinsun.com/tz/tz-link.htm) page for more information.
|
ezic is an erlang libraary for working with timezones. It compiles the Olson timezone database files into native erlang terms, which makes timezone lookup and zone conversion very fast. See the [tz database](http://www.twinsun.com/tz/tz-link.htm) page for more information about the Olson database.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Status
|
Status
|
||||||
------
|
------
|
||||||
|
|
||||||
|
2010.11.14
|
||||||
|
|
||||||
|
* The Zone/Rule flattening algorithm works correctly for a handful of tested zones. `ezic:local_to_utc/2` throws `ambiguous_zone` and `no_zone` errors where appropriate. Aside from bugs and edge cases that are sure to exist, and leap seconds, ezic is mostly functional.
|
||||||
|
|
||||||
2010.11.07
|
2010.11.07
|
||||||
|
|
||||||
* The time comparisons don't consider time relativity, so they're plain wrong. Within at least 24 hours of timechange or zone change, the results cannot be trusted.
|
* The time comparisons don't consider time relativity, so they're plain wrong. Within at least 24 hours of timechange or zone change, the results cannot be trusted.
|
||||||
@@ -34,8 +38,8 @@ API
|
|||||||
---
|
---
|
||||||
|
|
||||||
* `ezic:localtime(TimeZone) -> datetime()`
|
* `ezic:localtime(TimeZone) -> datetime()`
|
||||||
* `ezic:utc_to_time(universal_datetime(), TimeZone) -> local_datetime()`
|
* `ezic:utc_to_local(universal_datetime(), TimeZone) -> local_datetime()`
|
||||||
* `ezic:utc_from_time(local_datetime(), TimeZone) -> universal_datetime()`
|
* `ezic:local_to_utc(local_datetime(), TimeZone) -> universal_datetime()`
|
||||||
* `ezic:zone_convert(from_datetime(), TimeZoneFrom, TimeZoneTo) -> to_datetime()`
|
* `ezic:zone_convert(from_datetime(), TimeZoneFrom, TimeZoneTo) -> to_datetime()`
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +73,7 @@ Setup
|
|||||||
Purpose
|
Purpose
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Erlang/OTP doesn't have a timezone library, so I decided to write one.
|
Erlang/OTP didn't have a timezone library, so I wrote ezic to fill that void.
|
||||||
|
|
||||||
The [recommended way](http://www.erlang.org/pipermail/erlang-questions/2006-December/024291.html) 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:
|
The [recommended way](http://www.erlang.org/pipermail/erlang-questions/2006-December/024291.html) 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:
|
||||||
|
|
||||||
@@ -85,3 +89,5 @@ Acknowledgements
|
|||||||
----------------
|
----------------
|
||||||
|
|
||||||
I was inspired by the (anti-) license of the [SQLite project](http://www.sqlite.org/copyright.html) in my decision to release this into the public domain.
|
I was inspired by the (anti-) license of the [SQLite project](http://www.sqlite.org/copyright.html) in my decision to release this into the public domain.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
test/ezic_tests.erl
Normal file
10
test/ezic_tests.erl
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-module(ezic_tests).
|
||||||
|
-include("include/ezic.hrl").
|
||||||
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
local_to_utc_errors_test_() ->
|
||||||
|
ezic_db:init(),
|
||||||
|
[
|
||||||
|
?_assertError(ambiguous_zone, ezic:local_to_utc({{2010,11,7},{1,0,0}}, "America/Los_Angeles"))
|
||||||
|
, ?_assertError(no_zone, ezic:local_to_utc({{2010,3,14},{2,30,0}}, "America/Los_Angeles"))
|
||||||
|
].
|
||||||
@@ -3,9 +3,19 @@
|
|||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
all() ->
|
all() ->
|
||||||
eunit:test(ezic_record)
|
setup(),
|
||||||
|
|
||||||
|
eunit:test(ezic)
|
||||||
|
, eunit:test(ezic_record)
|
||||||
, eunit:test(ezic_date)
|
, eunit:test(ezic_date)
|
||||||
, eunit:test(ezic_zone)
|
, eunit:test(ezic_zone)
|
||||||
, eunit:test(ezic_parse)
|
, eunit:test(ezic_parse)
|
||||||
, eunit:test(ezic_rule)
|
, eunit:test(ezic_rule)
|
||||||
,ok.
|
,ok.
|
||||||
|
|
||||||
|
|
||||||
|
%% temporary db init because mnesia data gets corrupted between starting and stopping nodes.
|
||||||
|
setup()->
|
||||||
|
ezic_db:init(),
|
||||||
|
ezic:load("priv/tzdata"),
|
||||||
|
ezic_flatten:flatten().
|
||||||
|
|||||||
Reference in New Issue
Block a user