diff --git a/lib/iso9660/iso9660.c b/lib/iso9660/iso9660.c index cb249fb3..a41ae7cf 100644 --- a/lib/iso9660/iso9660.c +++ b/lib/iso9660/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.22 2006/03/17 03:19:15 rocky Exp $ + $Id: iso9660.c,v 1.23 2006/03/17 13:00:43 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein @@ -54,7 +54,7 @@ const char ISO_STANDARD_ID[] = {'C', 'D', '0', '0', '1'}; #include #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.22 2006/03/17 03:19:15 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.23 2006/03/17 13:00:43 rocky Exp $"; /* Variables to hold debugger-helping enumerations */ enum iso_enum1_s iso_enums1; @@ -239,7 +239,7 @@ iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date) represents a 15-minute interval. */ p_idr_date->dt_gmtoff = p_tm->tm_gmtoff / (15 * 60); - if (p_tm->tm_isdst) p_idr_date->dt_gmtoff -= 4; + if (p_tm->tm_isdst > 0) p_idr_date->dt_gmtoff -= 4; if (p_idr_date->dt_gmtoff < -48 ) { @@ -260,22 +260,39 @@ iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date) Set "long" time in format used in ISO 9660 primary volume descriptor from a Unix time structure. */ void -iso9660_set_ltime (const struct tm *_tm, /*out*/ iso9660_ltime_t *pvd_date) +iso9660_set_ltime (const struct tm *p_tm, /*out*/ iso9660_ltime_t *pvd_date) { char *_pvd_date = (char *) pvd_date; memset (_pvd_date, '0', 16); - _pvd_date[16] = (int8_t) 0; /* tz */ + _pvd_date[16] = (iso712_t) 0; /* Start out with time zone GMT. */ - if (!_tm) return; + if (!p_tm) return; snprintf(_pvd_date, 17, "%4.4d%2.2d%2.2d" "%2.2d%2.2d%2.2d" "%2.2d", - _tm->tm_year + 1900, _tm->tm_mon + 1, _tm->tm_mday, - _tm->tm_hour, _tm->tm_min, _tm->tm_sec, + p_tm->tm_year + 1900, p_tm->tm_mon + 1, p_tm->tm_mday, + p_tm->tm_hour, p_tm->tm_min, p_tm->tm_sec, 0 /* 1/100 secs */ ); - - _pvd_date[16] = (int8_t) 0; /* tz */ + + /* Adjust for daylight savings time. */ + if (p_tm->tm_isdst > 0) _pvd_date[16] -= (iso712_t) 4; + +#ifdef HAVE_TM_GMTOFF + /* Set time zone in 15-minute interval encoding. */ + _pvd_date[16] -= p_tm->tm_gmtoff / (15 * 60); + if (_pvd_date[16] < -48 ) { + + cdio_warn ("Converted ISO 9660 timezone %d is less than -48. Adjusted", + (int) _pvd_date[16]); + _pvd_date[16] = -48; + } else if (_pvd_date[16] > 52) { + cdio_warn ("Converted ISO 9660 timezone %d is over 52. Adjusted", + (int) _pvd_date[16]); + _pvd_date[16] = 52; + } +#endif + } /*! diff --git a/test/testiso9660.c b/test/testiso9660.c index 2659723c..d467c2c2 100644 --- a/test/testiso9660.c +++ b/test/testiso9660.c @@ -1,5 +1,5 @@ /* - $Id: testiso9660.c,v 1.9 2006/03/17 01:05:54 rocky Exp $ + $Id: testiso9660.c,v 1.10 2006/03/17 13:00:44 rocky Exp $ Copyright (C) 2003, 2006 Rocky Bernstein @@ -253,12 +253,21 @@ main (int argc, const char *argv[]) return 42; } + p_tm = localtime(&now); + iso9660_set_ltime(p_tm, <ime); + iso9660_get_ltime(<ime, &tm); + if ( ! time_compare(p_tm, &tm) ) { + printf("local time retrieved with iso9660_get_ltime() not same as\n"); + printf("that set with iso9660_set_ltime().\n"); + return 43; + } + iso9660_set_ltime(p_tm, <ime); iso9660_get_ltime(<ime, &tm); if ( ! time_compare(p_tm, &tm) ) { printf("GMT time retrieved with iso9660_get_ltime() not same as that\n"); printf("set with iso9660_set_ltime().\n"); - return 43; + return 44; } }