2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
19 #include <afs/ktime.h>
20 #include <afs/afsutil.h>
21 #include <afs/afsutil_prototypes.h>
22 #include <tests/tap/basic.h>
24 static struct testTime
{
29 { "now", 1, 0 }, /* lookup current time */
30 { "never", 0, (afs_int32
) -1 },
31 { "12/3/89", 0, 628664400 },
32 { "1/1/1", 0, 978325200 },
37 { "2/30/80", 0, 320734799 },
39 * Oh, well: note that 2/30 is bigger than any real date in February, and
40 * since this algorithm approaches the correct value from below, this is
41 * the closest it can come.
43 { "3/1/80", 0, 320734800 },
44 { "3/1/80 0:00", 0, 320734800 },
45 { "2/30/80 24:00", -2, 0 },
46 { "2/30/80 23:60", -2, 0 },
47 { "22/22/22", -2, 0 },
48 { "12/31/69 19:07", 0, 420 },
49 { "12/31/99 23:59", 0, 946702740 },
50 { "12/31/99 23:59:59", 0, 946702799 },
53 { "22/22/22 12", -1, 0 },
54 { "12/31/199 23:59:59", -2, 0 },
55 { "12/31/1888", -2, 0 },
56 { "-13/-44/22 -15:77", -2, 0 },
57 { "4/14/24", 0, 1713070800 },
58 { "4/14/2024", 0, 1713070800 },
59 { "4/14/68", 0, 0x7fffffff }, /* legal but w/sign bit on */
72 plan((sizeof(testTimes
) / sizeof(testTimes
[0]) - 1) * 2);
74 /* should do timezone and daylight savings time correction so this program
75 * work in other than EST */
78 for (tt
= testTimes
; tt
->time
; tt
++) {
80 code
= ktime_DateToLong(tt
->time
, &temp
);
83 is_int(0, code
, "ktime_DateToLong return for %s", tt
->time
);
84 ok((time(0) - t
<= 1), "ktime_DateToLong result for %s", tt
->time
);
86 is_int(tt
->code
, code
, "ktime_DateToLong return for %s", tt
->time
);
87 is_int(tt
->sec
, t
, "ktime_DateToLong result for %s", tt
->time
);