Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   dealing with timestamped data collected in one zone and reportedin another (http://www.velocityreviews.com/forums/t893076-dealing-with-timestamped-data-collected-in-one-zone-and-reportedin-another.html)

Mark Seger 06-28-2005 08:27 PM

dealing with timestamped data collected in one zone and reportedin another
 
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. 8-)

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

J. Gleixner 06-28-2005 08:54 PM

Re: dealing with timestamped data collected in one zone and reportedin another
 
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.

Big and Blue 06-28-2005 09:07 PM

Re: dealing with timestamped data collected in one zone and reportedin another
 
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.


All times are GMT. The time now is 05:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57