My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "time64.h"
#include <stdio.h>
#include "t/tap.c"

int main(void) {
struct TM date;
Time64_T time;

time = -10;
is_not_null( gmtime64_r(&time, &date), "gmtime / Wed Dec 31 23:59:50 1969" );
tm_ok(&date,
1969 - 1900, 11, 31,
23, 59, 50);


time = -0x00EFFFFFFFFFFFFFLL;
is_not_null( gmtime64_r(&time, &date), "gmtime / -2140698894-01-13 14:56:01" );
tm_ok(&date,
-2140698894 - 1900, 0, 13,
14, 56, 01);


/* Try something that results in a negative tm_year */
time = -4298423296LL;
is_not_null( gmtime64_r(&time, &date), "Tue Oct 15 17:31:44 1833" );
tm_ok(&date,
1833 - 1900, 9, 15,
17, 31, 44);

/* It is safe to assume that the year and month
will be the same, even with a julian/gregorian shift */
is_not_null( localtime64_r(&time, &date), "localtime" );
is_Int64((Year)date.tm_year, (Year)(1833 - 1900), "localtm.year");
is_int(date.tm_mon, 9, " .mon");


/* And now something that results in a negative real year */
time = -68719476736LL;
is_not_null( gmtime64_r(&time, &date), "Sun May 13 16:27:44 -208" );
tm_ok(&date,
-208 - 1900, 4, 13,
16, 27, 44);

is_not_null( localtime64_r(&time, &date), "localtime" );
is_Int64((Year)date.tm_year, (Year)(-208 - 1900), "localtm.year");
is_int(date.tm_mon, 4, " .mon");

done_testing();
return 0;
}

Change log

r91 by schwern on Oct 4, 2008   Diff
Remove is_ll(), which assumes long long,
and use is_Int64() instead.
Go to: 
Sign in to write a code review

Older revisions

r85 by schwern on Oct 3, 2008   Diff
Turn on -Wconversion to catch
conversion mistakes.

Fix a bunch of type conversion
warnings.
...
r70 by schwern on Sep 29, 2008   Diff
 r67112@windhund:  schwern |
2008-09-29 18:58:30 -0400
 Normalize the names of the TAP tests.
foo.t.c begats foo.t

...
r67 by schwern on Sep 29, 2008   Diff
 r67108@windhund:  schwern |
2008-09-29 15:51:31 -0400
 Rename localtime64.[hc] to
time64.[hc] and move tap.c into t/
All revisions of this file

File info

Size: 1521 bytes, 50 lines
Powered by Google Project Hosting