grub2: bring back build of aros-side grub2 tools
[AROS.git] / test / utility / amiga2date.c
blobe868b26c865150335d64a023ab51ac7c1a2c0c8c
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include <dos/dos.h>
9 #include <utility/date.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <proto/utility.h>
14 struct DateTime dt;
15 struct ClockData cd;
17 char s[100];
19 int main(void)
21 int retval = RETURN_OK;
23 dt.dat_StrDate = "31-dec-2000";
24 dt.dat_Format = FORMAT_DOS;
26 if (StrToDate(&dt))
28 dt.dat_StrDate = s;
29 if (DateToStr(&dt))
31 if (strcmp(s, "31-Dec-00")
32 || dt.dat_Stamp.ds_Days != 8400
33 || dt.dat_Stamp.ds_Minute != 0
34 || dt.dat_Stamp.ds_Tick != 0)
36 retval = RETURN_ERROR;
37 bug("DateToStr returned: \"%s\" days = %ld min = %ld tick = %ld\n",
39 (long)dt.dat_Stamp.ds_Days,
40 (long)dt.dat_Stamp.ds_Minute,
41 (long)dt.dat_Stamp.ds_Tick);
44 Amiga2Date(dt.dat_Stamp.ds_Days * 60 * 60 * 24 +
45 dt.dat_Stamp.ds_Minute * 60 +
46 dt.dat_Stamp.ds_Tick / 50, &cd);
48 if (cd.sec != 0
49 || cd.min != 0
50 || cd.hour != 0
51 || cd.mday != 31
52 || cd.month != 12
53 || cd.year != 2000
54 || cd.wday != 0)
56 retval = RETURN_ERROR;
57 bug("\nAmiga2Date says:\n\n");
58 bug("sec = %d\n", cd.sec);
59 bug("min = %d\n", cd.min);
60 bug("hour = %d\n", cd.hour);
61 bug("mday = %d\n", cd.mday);
62 bug("month = %d\n", cd.month);
63 bug("year = %d\n", cd.year);
64 bug("wday = %d\n", cd.wday);
67 Amiga2Date((dt.dat_Stamp.ds_Days + 1) * 60 * 60 * 24 +
68 dt.dat_Stamp.ds_Minute * 60 +
69 dt.dat_Stamp.ds_Tick / 50, &cd);
71 if (cd.sec != 0
72 || cd.min != 0
73 || cd.hour != 0
74 || cd.mday != 1
75 || cd.month != 1
76 || cd.year != 2001
77 || cd.wday != 1)
79 retval = RETURN_ERROR;
80 bug("\nAmiga2Date says (one day later:\n\n");
81 bug("sec = %d\n", cd.sec);
82 bug("min = %d\n", cd.min);
83 bug("hour = %d\n", cd.hour);
84 bug("mday = %d\n", cd.mday);
85 bug("month = %d\n", cd.month);
86 bug("year = %d\n", cd.year);
87 bug("wday = %d\n", cd.wday);
90 else
92 retval = RETURN_ERROR;
93 bug("Calling DateToStr failed!\n");
96 else
98 retval = RETURN_ERROR;
99 bug("Calling StrToDate failed!\n");
102 return retval;