Fixed a few warnings.
[tangerine.git] / arch / all-unix / battclock / readbattclock.c
blobed30a6e1a43c2ee0e3cdf125bc38d90cbfb568e2
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: ReadBattClock() function.
6 Lang: english
7 */
9 #include "battclock_intern.h"
10 #include <proto/battclock.h>
11 #include <proto/utility.h>
12 #include <utility/date.h>
13 #if 0
14 #include <aros/host-conf.h>
15 #endif
17 #include <time.h>
20 AROS_LH0(ULONG, ReadBattClock, struct BattClockBase *, BattClockBase, 2, Battclock)
22 AROS_LIBFUNC_INIT
25 This is mostly an example.
26 It is quite possible that this time value is not for the local
27 timezone, so it has to be converted.
29 time_t t;
30 struct tm *tm;
32 time(&t);
33 tm = localtime(&t);
35 #if 1
37 struct ClockData date;
39 date.year = tm->tm_year + 1900;
40 date.month = tm->tm_mon + 1;
41 date.mday = tm->tm_mday;
42 date.hour = tm->tm_hour;
43 date.min = tm->tm_min;
44 date.sec = tm->tm_sec;
46 return Date2Amiga(&date);
49 #else
51 This time is however relative to 1.1.1970, so we have to subtract a
52 large number of seconds so that things actually work correctly.
54 There is a problem here that 8 years before the Amiga clock dies,
55 the Unix system clock will have problems as it will wrap around.
56 Still, I'll be dead, and by then they won't be using 32-bit clocks
57 I expect...
59 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
60 return (t - 252460800 + tm->tm_gmtoff);
61 #else
62 return (t - 252460800);
63 #endif
64 #endif
66 AROS_LIBFUNC_EXIT
67 } /* ReadBattClock */