From 1e6e9fe4eddc08dcfba991416f149af0ba0cb6c6 Mon Sep 17 00:00:00 2001 From: Dmitry Melnikov Date: Sat, 18 Dec 2010 12:47:24 +0300 Subject: [PATCH] utests fixed --- README | 11 ++++++----- src/localtime_dst.erl | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README b/README index ef10d59..bd81f5c 100644 --- a/README +++ b/README @@ -1,9 +1,10 @@ This library contains four exported methods: -* utc_to_local(DateTime, Timezone) -* local_to_utc(DateTime, Timezone) -* local_to_local(DateTime, TimezoneFrom, TimezoneTo) -* tz_name(DateTime, Timezone) +* utc_to_local(DateTime, Timezone) - converts UTC time to local according to specified Timezone +* local_to_utc(DateTime, Timezone) - converts local time to UTC +* local_to_local(DateTime, TimezoneFrom, TimezoneTo) - converts local time to local +* 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 DateTime = {date(), time()} -TimeZone(To, From) = String(). E.g. “Europe/Moscow”, “America/NewYork” \ No newline at end of file +TimeZone(To, From) = String(). E.g. “Europe/Moscow”, “America/NewYork” diff --git a/src/localtime_dst.erl b/src/localtime_dst.erl index 9c62987..10b91f2 100644 --- a/src/localtime_dst.erl +++ b/src/localtime_dst.erl @@ -131,6 +131,8 @@ day_to_int(fri) -> 5; day_to_int(sat) -> 6; day_to_int(sun) -> 7. +time_to_minutes({Hours, Minutes}) -> + Hours * 60 + Minutes; time_to_minutes({Hours, Minutes, _Seconds}) -> Hours * 60 + Minutes. @@ -141,7 +143,7 @@ get_day_of_year_test() -> ?assertEqual(62, get_dst_day_of_year({1,wed,mar}, 2010)). 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_in_dst, check({{2010, 7, 8}, {10, 10, 0}}, Tz)), ?assertEqual(is_not_in_dst, check({{2010, 3, 28}, {1, 59, 0}}, Tz)),