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

Re: working patch for time offset calculation



2007/3/16, Joerg Schilling <Joerg.Schilling@fokus.fraunhofer.de>:
"Daniel Wasserhaus" <notgordan@gmail.com> wrote:

> 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:

Please provide test data that proves that my patch does not work.
I did test is with many offsets and it seem to work.

Hi Jörg,

ok, here is the test data. Since I did not want to screw my own
time/timezone settings, this was done inside a grml live-cd (ram
only). Booting grml with "grml gmt tz=America/New_York" bootoption and
building a vanilla cdrtools-2.01.01a24.tar.bz2 with make and setting
date to 05.01.2007 (to get rid of the current DST) gives the following
info:

root@grml ~/cdrtools-2.01.01 # date 01050000
Fri Jan  5 00:00:00 EST 2007
root@grml ~/cdrtools-2.01.01 # date -u
Fri Jan  5 05:00:03 UTC 2007

Next step is using the freshly built mkisofs to check the timezone:

root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # mkdir foo
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # ./mkisofs -o bar.iso foo
[...]
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # hexdump -C bar.iso
| grep 000083
00008320  20 20 20 20 20 20 20 20  20 20 20 20 20 32 30 30  |             200|
00008330  37 30 31 30 35 30 30 30  32 30 32 30 30 ec 32 30  |7010500020200ì20|
00008340  30 37 30 31 30 35 30 30  30 32 30 32 30 30 ec 30  |07010500020200ì0|
00008350  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 00  |000000000000000.|
00008360  32 30 30 37 30 31 30 35  30 30 30 32 30 32 30 30  |2007010500020200|
00008370  ec 01 00 20 20 20 20 20  20 20 20 20 20 20 20 20  |ì..             |
00008380  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |

Ok, we are 5 hours behind in this tz, so the 0xec at 0x833d, 0x834e
and 0x8370 are correct (0xec is the two's complement of 20 in dec
(20=5*(60/15)))
Now I set the time to new year's eve and check again:

root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # date -u 01010000
Mon Jan  1 00:00:00 UTC 2007
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # date
Sun Dec 31 19:00:04 EST 2006
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # ./mkisofs -o bar.iso foo
[...]
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # hexdump -C bar.iso
| grep 000083
00008320  20 20 20 20 20 20 20 20  20 20 20 20 20 32 30 30  |             200|
00008330  36 31 32 33 31 31 39 30  30 31 32 30 30 cc 32 30
|6123119001200Ã\21420|
00008340  30 36 31 32 33 31 31 39  30 30 31 32 30 30 cc 30
|06123119001200Ã\2140|
00008350  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 00  |000000000000000.|
00008360  32 30 30 36 31 32 33 31  31 39 30 30 31 32 30 30  |2006123119001200|
00008370  cc 01 00 20 20 20 20 20  20 20 20 20 20 20 20 20  |Ã\214..
         |
00008380  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |

0xcc is wrong, we are still 5 hours behind here (Jörg, I guess you
used just "date 01010000" to get to the new year's eve here, but as we
are behind gmt/utc both times would be in the same year already!)

Ok, reboot and do this all over with my patch applied to your current
alpha24 version:

root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # date -u 01010000
Mon Jan  1 00:00:00 UTC 2007
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # date
Sun Dec 31 19:00:04 EST 2006
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # ./mkisofs -o bar.iso foo
[...]
root@grml ...ls-2.01.01/mkisofs/OBJ/i686-linux-cc # hexdump -C bar.iso
| grep 000083
00008320  20 20 20 20 20 20 20 20  20 20 20 20 20 32 30 30  |             200|
00008330  36 31 32 33 31 31 39 30  30 35 36 30 30 ec 32 30  |6123119005600ì20|
00008340  30 36 31 32 33 31 31 39  30 30 35 36 30 30 ec 30  |06123119005600ì0|
00008350  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 00  |000000000000000.|
00008360  32 30 30 36 31 32 33 31  31 39 30 30 35 36 30 30  |2006123119005600|
00008370  ec 01 00 20 20 20 20 20  20 20 20 20 20 20 20 20  |ì..             |
00008380  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |

0xec is correct.

Greetings
gordan



Reply to: