dealing with timestamped data collected in one zone and reportedin another

Discussion in 'Perl Misc' started by Mark Seger, Jun 28, 2005.

  1. Mark Seger

    Mark Seger Guest

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

    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
    Mark Seger, Jun 28, 2005
    #1
    1. Advertising

  2. Mark Seger

    J. Gleixner Guest

    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.
    J. Gleixner, Jun 28, 2005
    #2
    1. Advertising

  3. Mark Seger

    Big and Blue Guest

    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.
    Big and Blue, Jun 28, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sg==?=

    When are static members garbage collected?

    =?Utf-8?B?Sg==?=, Feb 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    325
    bruce barker
    Feb 25, 2004
  2. =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=

    prevent a postback when moving web parts from zone to zone.

    =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=, Feb 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    574
    =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=
    Feb 8, 2006
  3. loveNUNO
    Replies:
    2
    Views:
    892
    loveNUNO
    Nov 20, 2003
  4. Ara.T.Howard
    Replies:
    0
    Views:
    75
    Ara.T.Howard
    Jul 20, 2005
  5. Replies:
    1
    Views:
    117
    M. Edward (Ed) Borasky
    Sep 19, 2006
Loading...

Share This Page