diff --git a/Makefile.aros b/Makefile.aros index bb44396..5c15325 100644 --- a/Makefile.aros +++ b/Makefile.aros @@ -10,7 +10,7 @@ BUGEMAIL= carsten.larsen@mail.com all: zic lib CC = gcc -CFLAGS = -O2 -DTZDIR=\"LOCALE:zoneinfo\" -DHAVE_ADJTIME=0 -DHAVE_STDINT_H=1 -DHAVE_STRFTIME_L=0 -DHAVE_DOS_FILE_NAMES -DHAVE_LINK=0 -DHAVE_SYMLINK=0 -DHAVE_TZSET=0 -DSTD_INSPIRED -Wall #-Werror +CFLAGS = -O2 -DTZDIR=\"LOCALE:zoneinfo\" -DHAVE_ADJTIME=0 -DHAVE_STDINT_H=1 -DHAVE_STRFTIME_L=0 -DHAVE_DOS_FILE_NAMES -DHAVE_LINK=0 -DHAVE_SYMLINK=0 -DHAVE_TZSET=0 -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -Dtime_tz=long -DTLOCALTIME_IMPLEMENTATION -Wall #-Werror LDFLAGS = LDLIBS = -lgcc -lm diff --git a/include/tz.h b/include/tz.h index cd56885..bf8609b 100644 --- a/include/tz.h +++ b/include/tz.h @@ -45,36 +45,56 @@ extern char *tzname[2]; -struct tm { - int tm_sec; /* seconds after the minute [0-61] */ - int tm_min; /* minutes after the hour [0-59] */ - int tm_hour; /* hours since midnight [0-23] */ - int tm_mday; /* day of the month [1-31] */ - int tm_mon; /* months since January [0-11] */ - int tm_year; /* years since 1900 */ - int tm_wday; /* days since Sunday [0-6] */ - int tm_yday; /* days since January 1 [0-365] */ - int tm_isdst; /* Daylight Savings Time flag */ - long tm_gmtoff; /* offset from UTC in seconds */ - char *tm_zone; /* timezone abbreviation */ +struct tz_tm { + int tm_sec; /* seconds after the minute [0-61] */ + int tm_min; /* minutes after the hour [0-59] */ + int tm_hour; /* hours since midnight [0-23] */ + int tm_mday; /* day of the month [1-31] */ + int tm_mon; /* months since January [0-11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday [0-6] */ + int tm_yday; /* days since January 1 [0-365] */ + int tm_isdst; /* Daylight Savings Time flag */ + long tm_gmtoff; /* offset from UTC in seconds */ + char *tm_zone; /* timezone abbreviation */ }; -typedef long time_t; +typedef long tz_time_t; typedef struct state *timezone_t; void tz_tzset(void); void tz_free(const timezone_t); timezone_t tz_alloc(const char *); -time_t tz_time(time_t *); -time_t tz_mktime_z(const timezone_t, struct tm *); -time_t tz_mktime(struct tm *); -struct tm *tz_localtime_rz(const timezone_t, const time_t *, struct tm *); -struct tm *tz_localtime_r(const time_t *, struct tm *); -struct tm *tz_localtime(const time_t *); -struct tm *tz_gmtime_r(const time_t *, struct tm *); -struct tm *tz_gmtime(const time_t *); -char *tz_ctime_r(const time_t *, char *); -char *tz_ctime(const time_t *); -char *asctime(const struct tm *); -char *asctime_r(const struct tm *, char *); -double tz_difftime(time_t, time_t); +tz_time_t tz_time(tz_time_t *); +tz_time_t tz_mktime_z(const timezone_t, struct tz_tm *); +tz_time_t tz_mktime(struct tz_tm *); +struct tz_tm *tz_localtime_rz(const timezone_t, const tz_time_t *, struct tz_tm *); +struct tz_tm *tz_localtime_r(const tz_time_t *, struct tz_tm *); +struct tz_tm *tz_localtime(const tz_time_t *); +struct tz_tm *tz_gmtime_r(const tz_time_t *, struct tz_tm *); +struct tz_tm *tz_gmtime(const tz_time_t *); +char *tz_ctime_r(const tz_time_t *, char *); +char *tz_ctime(const tz_time_t *); +//char *asctime_r(const struct tz_tm *, char *); +double tz_difftime(tz_time_t, tz_time_t); + +#ifndef HAVE_ASCTIME +//char *asctime(const struct tz_tm *); +#endif + +tz_time_t time(tz_time_t *x); + +#ifdef HAVENOSYSTIME +#include +tz_time_t time(tz_time_t *x) +{ + struct timeval tv; + GetSysTime(&tv); + + if (x) { + *x = (time_t)tv.tv_secs; + } + + return (time_t)tv.tv_secs; +} +#endif