Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > dealing with timestamped data collected in one zone and reportedin another

Reply
Thread Tools

dealing with timestamped data collected in one zone and reportedin another

 
 
Mark Seger
Guest
Posts: n/a
 
      06-28-2005
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
 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      06-28-2005
Mark Seger wrote:
[...]
> 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


For dealing with timezones, try the modules available under DateTime.
See CPAN or http://datetime.perl.org/ for more information.
 
Reply With Quote
 
 
 
 
Big and Blue
Guest
Posts: n/a
 
      06-28-2005
Mark Seger wrote:
>
> 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.


This is OS dependent. Most Unix systems (using Olson's time code)
would handle this correctly.

> Can someone help? Does someone have a better way to solve this problem?


Which OS are you using? Which OS is the final user going to be using?


--
Just because I've written it doesn't mean that
either you or I have to believe it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
a server that will serve http page created from data collected by "rsh" rajibsukanta@yahoo.co.in Ruby 1 09-19-2006 01:35 PM
prevent a postback when moving web parts from zone to zone. =?Utf-8?B?VmluY2UgVmFyYWxsbw==?= ASP .Net 0 02-08-2006 12:20 AM
[SCIRUBY] Thoughts on performance and garbage collected languages Ara.T.Howard Ruby 0 07-20-2005 05:55 PM
Zone Alarm or Zone Alarm Pro? Jones Computer Information 5 02-20-2004 07:29 PM
Using One XSLT and multiple XML Problem (One is XML and another one is XBRL) loveNUNO XML 2 11-20-2003 06:47 AM



Advertisments