2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Unix-based implementation of DateStamp()
8 #include <aros/system.h>
9 #include <exec/types.h>
10 #include <aros/libcall.h>
11 #include <aros/host-conf.h>
13 #define timeval sys_timeval
17 #include "dos_intern.h"
19 #define SECONDS_PER_DAY (60UL * 60 * 24)
20 #define SECONDS_PER_MINUTE (60UL)
21 #define uSEC_PER_SEC (1000000UL)
22 #define TICKS_PER_SEC (50UL)
23 #define uSEC_PER_TICK (uSEC_PER_SEC / TICKS_PER_SEC)
24 #define AMIGA_UNIX_OFFSET (2922UL) /* Days between 1.1.78 (Amiga) and 1.1.70 (Unix) */
26 AROS_LH1(struct DateStamp
*, DateStamp
,
27 AROS_LHA(struct DateStamp
*, date
, D1
),
28 struct DosLibrary
*, DOSBase
, 32, Dos
)
32 struct sys_timeval stv
;
33 gettimeofday (&stv
, NULL
);
35 date
->ds_Days
= stv
.tv_sec
/ SECONDS_PER_DAY
- AMIGA_UNIX_OFFSET
;
36 stv
.tv_sec
%= SECONDS_PER_DAY
;
37 date
->ds_Minute
= stv
.tv_sec
/ SECONDS_PER_MINUTE
;
38 stv
.tv_sec
%= SECONDS_PER_MINUTE
;
39 date
->ds_Tick
= (stv
.tv_usec
+ stv
.tv_sec
* uSEC_PER_SEC
) /