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>
15 #include <afs/ktime.h>
16 #include <tap/basic.h>
18 static struct testTime {
23 { "now", 1, 0 }, /* lookup current time */
24 { "never", 0, 0xffffffff },
25 { "12/3/89", 0, 628664400 },
26 { "1/1/1", 0, 978325200 },
31 { "2/30/80", 0, 320734799 },
33 * Oh, well: note that 2/30 is bigger than any real date in February, and
34 * since this algorithm approaches the correct value from below, this is
35 * the closest it can come.
37 { "3/1/80", 0, 320734800 },
38 { "3/1/80 0:00", 0, 320734800 },
39 { "2/30/80 24:00", -2, 0 },
40 { "2/30/80 23:60", -2, 0 },
41 { "22/22/22", -2, 0 },
42 { "12/31/69 19:07", 0, 420 },
43 { "12/31/99 23:59", 0, 946702740 },
44 { "12/31/99 23:59:59", 0, 946702799 },
47 { "22/22/22 12", -1, 0 },
48 { "12/31/199 23:59:59", -2, 0 },
49 { "12/31/1888", -2, 0 },
50 { "-13/-44/22 -15:77", -2, 0 },
51 { "4/14/24", 0, 1713070800 },
52 { "4/14/2024", 0, 1713070800 },
53 { "4/14/68", 0, 0x7fffffff }, /* legal but w/sign bit on */
66 plan((sizeof(testTimes) / sizeof(testTimes[0]) - 1) * 2);
68 /* should do timezone and daylight savings time correction so this program
69 * work in other than EST */
73 for (tt = testTimes; tt->time; tt++) {
75 code = ktime_DateToLong(tt->time, &t);
77 is_int(0, code, "ktime_DateToLong return for %s", tt->time);
78 ok((time(0) - t <= 1), "ktime_DateToLong result for %s", tt->time);
80 is_int(tt->code, code, "ktime_DateToLong return for %s", tt->time);
81 is_int(tt->sec, t, "ktime_DateToLong result for %s", tt->time);