Use StrDup() because it checks if memory allocation succeeded.
[AROS.git] / test / strtodate.c
blob7486d2d7e950070d62319dd544672e5cce68ecc1
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/dos.h>
9 #include <string.h>
10 #include <stdio.h>
12 struct DateTime dt;
13 struct DateStamp ds;
14 char s[100];
16 LONG days = 0;
18 int main(void)
22 dt.dat_Stamp.ds_Days = days;
23 dt.dat_Format = FORMAT_DOS;
24 dt.dat_StrDate = s;
26 DateToStr(&dt);
28 dt.dat_Stamp.ds_Days = -1;
29 StrToDate(&dt);
31 //printf("date \"%s\" day = %ld\n", s, days);
33 if (dt.dat_Stamp.ds_Days != days)
35 printf("Bad results for date \"%s\" (day #%ld). "
36 "StrToDate thought it was day #%ld\n", s, (long)days, (long)dt.dat_Stamp.ds_Days);
39 days++;
41 } while (!CheckSignal(SIGBREAKF_CTRL_C)
42 && (days < 36525)); /* 2078-01-01: same as 1978 in FORMAT_DOS */
44 return 0;