utests fixed
This commit is contained in:
parent
4f3e906ad3
commit
1e6e9fe4ed
2 changed files with 9 additions and 6 deletions
9
README
9
README
|
@ -1,9 +1,10 @@
|
||||||
This library contains four exported methods:
|
This library contains four exported methods:
|
||||||
|
|
||||||
* utc_to_local(DateTime, Timezone)
|
* utc_to_local(DateTime, Timezone) - converts UTC time to local according to specified Timezone
|
||||||
* local_to_utc(DateTime, Timezone)
|
* local_to_utc(DateTime, Timezone) - converts local time to UTC
|
||||||
* local_to_local(DateTime, TimezoneFrom, TimezoneTo)
|
* local_to_local(DateTime, TimezoneFrom, TimezoneTo) - converts local time to local
|
||||||
* tz_name(DateTime, Timezone)
|
* tz_name(DateTime, Timezone) - returns a timezone name (E.g. MSK, MSD, etc)
|
||||||
|
* tz_shift(DateTime, Timezone) - return shift from local datetime to GMT
|
||||||
Where
|
Where
|
||||||
DateTime = {date(), time()}
|
DateTime = {date(), time()}
|
||||||
TimeZone(To, From) = String(). E.g. “Europe/Moscow”, “America/NewYork”
|
TimeZone(To, From) = String(). E.g. “Europe/Moscow”, “America/NewYork”
|
|
@ -131,6 +131,8 @@ day_to_int(fri) -> 5;
|
||||||
day_to_int(sat) -> 6;
|
day_to_int(sat) -> 6;
|
||||||
day_to_int(sun) -> 7.
|
day_to_int(sun) -> 7.
|
||||||
|
|
||||||
|
time_to_minutes({Hours, Minutes}) ->
|
||||||
|
Hours * 60 + Minutes;
|
||||||
time_to_minutes({Hours, Minutes, _Seconds}) ->
|
time_to_minutes({Hours, Minutes, _Seconds}) ->
|
||||||
Hours * 60 + Minutes.
|
Hours * 60 + Minutes.
|
||||||
|
|
||||||
|
@ -141,7 +143,7 @@ get_day_of_year_test() ->
|
||||||
?assertEqual(62, get_dst_day_of_year({1,wed,mar}, 2010)).
|
?assertEqual(62, get_dst_day_of_year({1,wed,mar}, 2010)).
|
||||||
|
|
||||||
check_test() ->
|
check_test() ->
|
||||||
Tz = {"Europe/Moscow",{"MSK","MSK"},{"MSD","MSD"},{3,0},{1,0},{last,sun,mar},{2,0},{last,sun,oct},{3,0}},
|
Tz = {"Europe/Moscow",{"MSK","MSK"},{"MSD","MSD"},180,60,{last,sun,mar},{2,0},{last,sun,oct},{3,0}},
|
||||||
?assertEqual(is_not_in_dst, localtime_dst:check({{2010, 1, 1}, {10, 10, 0}}, Tz)),
|
?assertEqual(is_not_in_dst, localtime_dst:check({{2010, 1, 1}, {10, 10, 0}}, Tz)),
|
||||||
?assertEqual(is_in_dst, check({{2010, 7, 8}, {10, 10, 0}}, Tz)),
|
?assertEqual(is_in_dst, check({{2010, 7, 8}, {10, 10, 0}}, Tz)),
|
||||||
?assertEqual(is_not_in_dst, check({{2010, 3, 28}, {1, 59, 0}}, Tz)),
|
?assertEqual(is_not_in_dst, check({{2010, 3, 28}, {1, 59, 0}}, Tz)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue