[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

working patch for time offset calculation



Hi,

I just looked through the latest cdrtools-2.01.01a24 release to see if
Jörg has applied my patch for the timezone calculation. Well, he's
using a different way to calculate the timezone offset now:

local.tm_min -= gmt.tm_min;
local.tm_hour -= gmt.tm_hour;
local.tm_yday -= gmt.tm_yday;
if (local.tm_yday < -2) /* Hit new-year limit */
 local.tm_yday = 1; /* Local is GMT + 1 day */
iso_time[16] = (local.tm_min + 60 *
 (local.tm_hour + 24 * local.tm_yday)) / 15;

But this only works for those east of greenwich! If you are in a tz
behind GMT/UTC, like the USA, the if expression never catches
(local.tm_yday would be > 2 when local.tm_year != gmt.tm_year). I must
admit though, that my posted patch with the following calculation:

local.tm_min -= gmt.tm_min;
local.tm_hour -= gmt.tm_hour;
local.tm_yday -= gmt.tm_yday;
local.tm_year -= gmt.tm_year;
iso_time[16] = (local.tm_min + 60 *
 (local.tm_hour + 24 * (local.tm_year || local.tm_yday))) / 15;

also fails in this case as local.tm_year would be -1, the
(local.tm_year || local.tm_yday) expression then in turn would be
evaluated to 1 (and not to -1 as I thought). Haven't done much
C-coding lately, and those things are handled differently
everywhere...

So here is my new (hopefully working) suggestion:

diff -ru cdrtools-2.01.01.orig/mkisofs/write.c cdrtools-2.01.01/mkisofs/write.c
--- cdrtools-2.01.01.orig/mkisofs/write.c       2007-02-17
16:48:16.000000000 +0100
+++ cdrtools-2.01.01/mkisofs/write.c    2007-03-15 22:45:59.000000000 +0100
@@ -1742,8 +1742,9 @@
       local.tm_min -= gmt.tm_min;
       local.tm_hour -= gmt.tm_hour;
       local.tm_yday -= gmt.tm_yday;
-       if (local.tm_yday < -2)         /* Hit new-year limit   */
-               local.tm_yday = 1;      /* Local is GMT + 1 day */
+       local.tm_year -= gmt.tm_year;
+       if (local.tm_year)
+               local.tm_yday = local.tm_year;
       iso_time[16] = (local.tm_min + 60 *
                               (local.tm_hour + 24 * local.tm_yday)) / 15;

Greetings
gordan



Reply to: