Handled platform specific differences in time zone calculation.

This commit is contained in:
Alexander Nedotsukov 2006-10-19 08:12:29 +00:00
parent a8d9882280
commit 4dbae90e80
3 changed files with 27 additions and 11 deletions

View File

@ -3,4 +3,5 @@
aclocal aclocal
libtoolize --copy --force libtoolize --copy --force
autoconf autoconf
autoheader
automake --foreign --add-missing --copy --include-deps automake --foreign --add-missing --copy --include-deps

View File

@ -7,6 +7,8 @@ AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([subdir-objects]) AM_INIT_AUTOMAKE([subdir-objects])
AM_CONFIG_HEADER(config.h)
dnl Making releases: dnl Making releases:
dnl BURN_MICRO_VERSION += 1; dnl BURN_MICRO_VERSION += 1;
dnl BURN_INTERFACE_AGE += 1; dnl BURN_INTERFACE_AGE += 1;
@ -69,6 +71,12 @@ AC_PROG_INSTALL
AC_CHECK_HEADERS() AC_CHECK_HEADERS()
AC_CHECK_MEMBER([struct tm.tm_gmtoff],
[AC_DEFINE(HAVE_TM_GMTOFF, 1,
[Define this if tm structure includes a tm_gmtoff entry.])],
,
[#include <time.h>])
THREAD_LIBS=-lpthread THREAD_LIBS=-lpthread
AC_SUBST(THREAD_LIBS) AC_SUBST(THREAD_LIBS)

View File

@ -4,6 +4,9 @@
/** /**
* Utility functions for the Libisofs library. * Utility functions for the Libisofs library.
*/ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wchar.h> #include <wchar.h>
#include <iconv.h> #include <iconv.h>
@ -421,16 +424,11 @@ void iso_bb(uint8_t *buf, uint32_t num, int bytes)
void iso_datetime_7(unsigned char *buf, time_t t) void iso_datetime_7(unsigned char *buf, time_t t)
{ {
static int tzsetup = 0; static int tzsetup = 0;
static int tzoffset; int tzoffset;
struct tm tm; struct tm tm;
if (!tzsetup) { if (!tzsetup) {
tzset(); tzset();
tzoffset = -timezone / 60 / 15;
if (tzoffset < -48)
tzoffset += 101;
tzsetup = 1; tzsetup = 1;
} }
@ -442,6 +440,13 @@ void iso_datetime_7(unsigned char *buf, time_t t)
buf[3] = tm.tm_hour; buf[3] = tm.tm_hour;
buf[4] = tm.tm_min; buf[4] = tm.tm_min;
buf[5] = tm.tm_sec; buf[5] = tm.tm_sec;
#ifdef HAVE_TM_GMTOFF
tzoffset = -tm.tm_gmtoff / 60 / 15;
#else
tzoffset = -timezone / 60 / 15;
#endif
if (tzoffset < -48)
tzoffset += 101;
buf[6] = tzoffset; buf[6] = tzoffset;
} }
@ -472,11 +477,6 @@ void iso_datetime_17(unsigned char *buf, time_t t)
} else { } else {
if (!tzsetup) { if (!tzsetup) {
tzset(); tzset();
tzoffset = -timezone / 60 / 15;
if (tzoffset < -48)
tzoffset += 101;
tzsetup = 1; tzsetup = 1;
} }
@ -489,6 +489,13 @@ void iso_datetime_17(unsigned char *buf, time_t t)
sprintf((char*)&buf[10], "%02d", tm.tm_min); sprintf((char*)&buf[10], "%02d", tm.tm_min);
sprintf((char*)&buf[12], "%02d", MIN(59, tm.tm_sec)); sprintf((char*)&buf[12], "%02d", MIN(59, tm.tm_sec));
memcpy(&buf[14], "00", 2); memcpy(&buf[14], "00", 2);
#ifdef HAVE_TM_GMTOFF
tzoffset = -tm.tm_gmtoff / 60 / 15;
#else
tzoffset = -timezone / 60 / 15;
#endif
if (tzoffset < -48)
tzoffset += 101;
buf[16] = tzoffset; buf[16] = tzoffset;
} }
} }