Humble script for creating the port's snapshots.
[AROS.git] / test / date2amiga.c
blobeaae41d4dc94472942eb0bb89a013c28d67dea27
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/datetime.h>
7 #include <dos/dos.h>
8 #include <proto/exec.h>
9 #include <proto/dos.h>
10 #include <proto/utility.h>
11 #include <utility/date.h>
12 #include <string.h>
13 #include <stdio.h>
15 struct UtilityBase *UtilityBase;
16 struct DateTime dt;
17 struct DateStamp ds;
18 struct ClockData cd;
20 char s[100];
22 LONG days = 0;
23 ULONG seconds = 0;
24 ULONG secresult;
26 int main(void)
28 if (!(UtilityBase = (struct UtilityBase *)OpenLibrary("utility.library", 36)))
30 printf("Can't open utility.library!\n");
32 else
36 dt.dat_Stamp.ds_Days = days;
37 dt.dat_Format = FORMAT_DOS;
38 dt.dat_StrDate = s;
40 DateToStr(&dt);
42 dt.dat_Stamp.ds_Days = -1;
43 StrToDate(&dt);
45 //printf("date \"%s\" day = %ld\n", s, days);
47 if (dt.dat_Stamp.ds_Days != days)
49 printf("StrToDate showed bad results for date \"%s\" (day #%ld). "
50 "StrToDate thought it was day #%ld\n", s, (long)days, (long)dt.dat_Stamp.ds_Days);
52 else
54 Amiga2Date(seconds, &cd);
55 if ((secresult = Date2Amiga(&cd)) != seconds)
57 printf("Date2Amiga gave wrong values for date \"%s\" (day #%ld)"
58 " (secs %ld) -> wrong secs is %ld"
59 " --> clockdate: year = %d month = %d day = %d\n"
60 , s, (long)days, (long)seconds, (long)secresult, (int)cd.year, (int)cd.month, (int)cd.mday);
65 days++;
66 seconds += 86400;
68 } while (days < 36525 /* 2078-01-01: same as 1978 in FORMAT_DOS */
69 && (SetSignal(0, 0) & SIGBREAKF_CTRL_C) == 0);
71 CloseLibrary((struct Library *)UtilityBase);
74 return 0;