32
-export([all/1, univ_to_local/1, local_to_univ/1,
32
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
33
init_per_group/2,end_per_group/2, univ_to_local/1, local_to_univ/1,
33
34
bad_univ_to_local/1, bad_local_to_univ/1,
35
univ_to_seconds/1, seconds_to_univ/1,
35
now/1, now_unique/1, now_update/1, timestamp/1]).
37
now_unique/1, now_update/1, timestamp/1]).
37
39
-export([local_to_univ_utc/1]).
39
-include("test_server.hrl").
41
-include_lib("test_server/include/test_server.hrl").
41
43
-export([linear_time/1]).
55
57
-define(dst_timezone, 2).
57
all(suite) -> [univ_to_local, local_to_univ,
59
bad_univ_to_local, bad_local_to_univ,
60
consistency, now, timestamp].
59
suite() -> [{ct_hooks,[ts_install_cth]}].
62
[univ_to_local, local_to_univ, local_to_univ_utc,
63
bad_univ_to_local, bad_local_to_univ,
64
univ_to_seconds, seconds_to_univ,
66
{group, now}, timestamp].
69
[{now, [], [now_unique, now_update]}].
71
init_per_suite(Config) ->
74
end_per_suite(_Config) ->
77
init_per_group(_GroupName, Config) ->
80
end_per_group(_GroupName, Config) ->
62
84
local_to_univ_utc(suite) ->
143
165
bad_test_local_to_univ([]) ->
169
%% Test universaltime to seconds conversions
170
univ_to_seconds(Config) when is_list(Config) ->
171
test_univ_to_seconds(ok_utc_seconds()).
173
test_univ_to_seconds([{Datetime, Seconds}|DSs]) ->
174
io:format("universaltime = ~p -> seconds = ~p", [Datetime, Seconds]),
175
Seconds = erlang:universaltime_to_posixtime(Datetime),
176
test_univ_to_seconds(DSs);
177
test_univ_to_seconds([]) ->
180
%% Test seconds to universaltime conversions
181
seconds_to_univ(Config) when is_list(Config) ->
182
test_seconds_to_univ(ok_utc_seconds()).
184
test_seconds_to_univ([{Datetime, Seconds}|DSs]) ->
185
io:format("universaltime = ~p <- seconds = ~p", [Datetime, Seconds]),
186
Datetime = erlang:posixtime_to_universaltime(Seconds),
187
test_seconds_to_univ(DSs);
188
test_seconds_to_univ([]) ->
146
192
%% Test that the the different time functions return
147
193
%% consistent results. (See the test case for assumptions
148
194
%% and limitations.)
483
%% exakt utc {date(), time()} which corresponds to the same seconds since 1 jan 1970
484
%% negative seconds are ok
485
%% generated with date --date='1979-05-28 12:30:35 UTC' +%s
486
ok_utc_seconds() -> [
487
{ {{1970, 1, 1},{ 0, 0, 0}}, 0 },
488
{ {{1970, 1, 1},{ 0, 0, 1}}, 1 },
489
{ {{1969,12,31},{23,59,59}}, -1 },
490
{ {{1920,12,31},{23,59,59}}, -1546300801 },
491
{ {{1600,02,19},{15,14,08}}, -11671807552 },
492
{ {{1979,05,28},{12,30,35}}, 296742635 },
493
{ {{1999,12,31},{23,59,59}}, 946684799 },
494
{ {{2000, 1, 1},{ 0, 0, 0}}, 946684800 },
495
{ {{2000, 1, 1},{ 0, 0, 1}}, 946684801 },
497
{ {{2038, 1,19},{03,14,07}}, 2147483647 }, % Sint32 full - 1
498
{ {{2038, 1,19},{03,14,08}}, 2147483648 }, % Sint32 full
499
{ {{2038, 1,19},{03,14,09}}, 2147483649 }, % Sint32 full + 1
501
{ {{2106, 2, 7},{ 6,28,14}}, 4294967294 }, % Uint32 full 0xFFFFFFFF - 1
502
{ {{2106, 2, 7},{ 6,28,15}}, 4294967295 }, % Uint32 full 0xFFFFFFFF
503
{ {{2106, 2, 7},{ 6,28,16}}, 4294967296 }, % Uint32 full 0xFFFFFFFF + 1
504
{ {{2012,12, 6},{16,28,08}}, 1354811288 },
505
{ {{2412,12, 6},{16,28,08}}, 13977592088 }
438
509
%% The following dates should not be near the end or beginning of
439
510
%% a month, because they will be used to test when the dates are
440
511
%% different in UTC and local time.