compiler/clib: a little more clean-up
[AROS.git] / test / amiga2date.c
blobab639dc88ece8301d4f8646d674a8f371393d182
1 #include <aros/debug.h>
3 #include <dos/dos.h>
4 #include <utility/date.h>
5 #include <proto/exec.h>
6 #include <proto/dos.h>
7 #include <proto/utility.h>
9 struct DateTime dt;
10 struct ClockData cd;
12 char s[100];
14 int main(void)
16 int retval = RETURN_OK;
18 dt.dat_StrDate = "31-dec-2000";
19 dt.dat_Format = FORMAT_DOS;
21 if (StrToDate(&dt))
23 dt.dat_StrDate = s;
24 if (DateToStr(&dt))
26 if (strcmp(s, "31-Dec-00")
27 || dt.dat_Stamp.ds_Days != 8400
28 || dt.dat_Stamp.ds_Minute != 0
29 || dt.dat_Stamp.ds_Tick != 0)
31 retval = RETURN_ERROR;
32 bug("DateToStr returned: \"%s\" days = %ld min = %ld tick = %ld\n",
34 (long)dt.dat_Stamp.ds_Days,
35 (long)dt.dat_Stamp.ds_Minute,
36 (long)dt.dat_Stamp.ds_Tick);
39 Amiga2Date(dt.dat_Stamp.ds_Days * 60 * 60 * 24 +
40 dt.dat_Stamp.ds_Minute * 60 +
41 dt.dat_Stamp.ds_Tick / 50, &cd);
43 if (cd.sec != 0
44 || cd.min != 0
45 || cd.hour != 0
46 || cd.mday != 31
47 || cd.month != 12
48 || cd.year != 2000
49 || cd.wday != 0)
51 retval = RETURN_ERROR;
52 bug("\nAmiga2Date says:\n\n");
53 bug("sec = %d\n", cd.sec);
54 bug("min = %d\n", cd.min);
55 bug("hour = %d\n", cd.hour);
56 bug("mday = %d\n", cd.mday);
57 bug("month = %d\n", cd.month);
58 bug("year = %d\n", cd.year);
59 bug("wday = %d\n", cd.wday);
62 Amiga2Date((dt.dat_Stamp.ds_Days + 1) * 60 * 60 * 24 +
63 dt.dat_Stamp.ds_Minute * 60 +
64 dt.dat_Stamp.ds_Tick / 50, &cd);
66 if (cd.sec != 0
67 || cd.min != 0
68 || cd.hour != 0
69 || cd.mday != 1
70 || cd.month != 1
71 || cd.year != 2001
72 || cd.wday != 1)
74 retval = RETURN_ERROR;
75 bug("\nAmiga2Date says (one day later:\n\n");
76 bug("sec = %d\n", cd.sec);
77 bug("min = %d\n", cd.min);
78 bug("hour = %d\n", cd.hour);
79 bug("mday = %d\n", cd.mday);
80 bug("month = %d\n", cd.month);
81 bug("year = %d\n", cd.year);
82 bug("wday = %d\n", cd.wday);
85 else
87 retval = RETURN_ERROR;
88 bug("Calling DateToStr failed!\n");
91 else
93 retval = RETURN_ERROR;
94 bug("Calling StrToDate failed!\n");
97 return retval;