2 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
5 Query the current time and/or timezone.
8 #include <proto/exec.h>
9 #include <proto/timer.h>
10 #include <exec/types.h>
11 #include <aros/symbolsets.h>
12 #include <aros/debug.h>
17 #include "__posixc_time.h"
19 /*****************************************************************************
31 Return the current time and/or timezone.
34 tv - If this pointer is non-NULL, the current time will be
35 stored here. The structure looks like this:
39 long tv_sec; // seconds
40 long tv_usec; // microseconds
43 tz - If this pointer is non-NULL, the current timezone will be
44 stored here. The structure looks like this:
48 int tz_minuteswest; // minutes west of Greenwich
49 int tz_dsttime; // type of dst correction
52 With daylight savings times defined as follows :
54 DST_NONE // not on dst
55 DST_USA // USA style dst
56 DST_AUST // Australian style dst
57 DST_WET // Western European dst
58 DST_MET // Middle European dst
59 DST_EET // Eastern European dst
61 DST_GB // Great Britain and Eire
64 DST_AUSTALT // Australian style with shift in 1986
66 And the following macros are defined to operate on this :
68 timerisset(tv) - TRUE if tv contains a time
70 timercmp(tv1, tv2, cmp) - Return the result of the
71 comparison "tv1 cmp tv2"
73 timerclear(tv) - Clear the timeval struct
76 The number of seconds.
79 This function must not be used in a shared library or
80 in a threaded application.
85 // Get the current time and print it
86 gettimeofday (&tv, NULL);
88 printf ("Seconds = %ld, uSec = %ld\n", tv->tv_sec, tv->tv_usec);
93 stdc.library/ctime(), stdc.library/asctime(), stdc.library/localtime(),
98 ******************************************************************************/
100 struct PosixCIntBase
*PosixCBase
= (struct PosixCIntBase
*)__aros_getbase_PosixCBase();
103 __init_timerbase(PosixCBase
);
111 /* Adjust with the current timezone, stored in minutes west of GMT */
112 tv
->tv_sec
+= (2922 * 1440 + __stdc_gmtoffset()) * 60;
123 tz
->tz_minuteswest
= __stdc_gmtoffset();
124 /* FIXME: set tz->tz_dsttime */
125 tz
->tz_dsttime
= DST_NONE
;