M
Mark Seger
I'm surprised I can't find what I'm trying to do in existing modules or
maybe I'm just not looking in the right places.
I'm creating some time based logs (recording the UTC as reported by
gettimeofday()) in one timezone and I want to play them back in another,
showing the times on the system where they were initially recorded. In
other words, if I record a file in stockholm which is GMT +2 and play it
back in Boston which is GMT -4, data recorded at midnight in stockholm
shows up 6 hours earlier because of the time difference.
The simple solution, and this is too simple as I'll get to in a minute,
is to just record the timezone where the data was recorded. That way
when I go to play it back I can tell there is a 6 hour difference and
simply adjust the times accordingly before calling localtime() to
convert them. This works like a champ, but...
Although many countries around the world support daylight savings time,
they do not do it on the same date! In other words, if I use my simple
algorithm above it will break when one country has adjusted its clocks
and the other hasn't. The one simple solution I can think of that will
make this all work is that if I were do know my offset from GMT not for
the current date, but for the date of the data I wish to process. But I
can't seem to find any such function.
Can someone help? Does someone have a better way to solve this problem?
-mark
maybe I'm just not looking in the right places.
I'm creating some time based logs (recording the UTC as reported by
gettimeofday()) in one timezone and I want to play them back in another,
showing the times on the system where they were initially recorded. In
other words, if I record a file in stockholm which is GMT +2 and play it
back in Boston which is GMT -4, data recorded at midnight in stockholm
shows up 6 hours earlier because of the time difference.
The simple solution, and this is too simple as I'll get to in a minute,
is to just record the timezone where the data was recorded. That way
when I go to play it back I can tell there is a 6 hour difference and
simply adjust the times accordingly before calling localtime() to
convert them. This works like a champ, but...
Although many countries around the world support daylight savings time,
they do not do it on the same date! In other words, if I use my simple
algorithm above it will break when one country has adjusted its clocks
and the other hasn't. The one simple solution I can think of that will
make this all work is that if I were do know my offset from GMT not for
the current date, but for the date of the data I wish to process. But I
can't seem to find any such function.
Can someone help? Does someone have a better way to solve this problem?
-mark