diff options
author | Imre Horvath <[email protected]> | 2010-12-14 23:03:44 +0100 |
---|---|---|
committer | Niclas Axelsson <[email protected]> | 2011-03-02 16:15:37 +0100 |
commit | 7c94e6f3a69462968cfd352fb40389454bd42e7e (patch) | |
tree | 3edd3b534f34e476a3a08b8f9f49fd0b14684d79 /lib/stdlib/test | |
parent | bbed1363f171199b3d87145d8a5e2c1875ca90ca (diff) | |
download | otp-7c94e6f3a69462968cfd352fb40389454bd42e7e.tar.gz otp-7c94e6f3a69462968cfd352fb40389454bd42e7e.tar.bz2 otp-7c94e6f3a69462968cfd352fb40389454bd42e7e.zip |
Add ISO week number calculation functions to the calendar module in stdlib
This new feature adds the missing week number function to the calendar module
of the stdlib application. The implementation conforms to the ISO 8601 standard.
The new feature has been implemented tested and documented.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r-- | lib/stdlib/test/calendar_SUITE.erl | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/stdlib/test/calendar_SUITE.erl b/lib/stdlib/test/calendar_SUITE.erl index 81b0299118..8192d035ca 100644 --- a/lib/stdlib/test/calendar_SUITE.erl +++ b/lib/stdlib/test/calendar_SUITE.erl @@ -28,7 +28,8 @@ day_of_the_week_calibrate/1, leap_years/1, last_day_of_the_month/1, - local_time_to_universal_time_dst/1]). + local_time_to_universal_time_dst/1, + iso_week_number/1]). -define(START_YEAR, 1947). -define(END_YEAR, 2012). @@ -38,7 +39,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [gregorian_days, gregorian_seconds, day_of_the_week, day_of_the_week_calibrate, leap_years, - last_day_of_the_month, local_time_to_universal_time_dst]. + last_day_of_the_month, local_time_to_universal_time_dst, iso_week_number]. groups() -> []. @@ -55,7 +56,6 @@ init_per_group(_GroupName, Config) -> end_per_group(_GroupName, Config) -> Config. - gregorian_days(doc) -> "Tests that date_to_gregorian_days and gregorian_days_to_date " "are each others inverses from ?START_YEAR-01-01 up to ?END_YEAR-01-01. " @@ -170,6 +170,15 @@ local_time_to_universal_time_dst_x(Config) when is_list(Config) -> {comment,"Bug in mktime() in this OS"} end. +iso_week_number(doc) -> + "Test the iso week number calculation for all three possibilities." + " When the date falls on the last week of the previous year," + " when the date falls on a week within the given year and finally," + " when the date falls on the first week of the next year."; +iso_week_number(suite) -> + []; +iso_week_number(Config) when is_list(Config) -> + ?line check_iso_week_number(). %% %% LOCAL FUNCTIONS @@ -259,7 +268,12 @@ check_last_day_of_the_month({SYr, SMon}, {EYr, EMon}) when SYr < EYr -> check_last_day_of_the_month(_, _) -> ok. - +%% check_iso_week_number +%% +check_iso_week_number() -> + ?line {2004, 53} = calendar:iso_week_number({2005, 1, 1}), + ?line {2007, 1} = calendar:iso_week_number({2007, 1, 1}), + ?line {2009, 1} = calendar:iso_week_number({2008, 12, 29}). |