Is there a perl package, or data in a form easily used by a perlscript, that can be used to determin

Discussion in 'Perl Misc' started by Ted Byers, Nov 6, 2008.

  1. Ted Byers

    Ted Byers Guest

    NB: I have seen information about using the system's settings, but
    that is not relevant to this problem.

    I have a number of DB tables that have datetime values defined WRT UTC
    time. If all users could/would work with UTC, there'd be no problem.
    I have stored, in a users table, the users' specific timezones. So
    far so good. I can use Date::Manip to convert from UTC to each user's
    timezone easily. That is great!

    However, in many localities, there is a need to switch to and from a
    daylight savings time, and I can use the time zones defined in
    Date::Manip to specify which users would be using daylight savings
    time, but the problem is that using something like "EST5EDT" in either
    $from or $to Date_ConvTZ($date1,$from,$to1); does nothing (i.e. the
    value returned is identical to $date1). In some respects, I was not
    very surprised: unless there was some kind of database hidden in the
    bowels of Date::Manip, it couldn't know when to switch to or from
    daylight savings time based on the value of $date1. I would not have
    a problem creating my own function to do the converstion (dispatching
    to Date_ConvTZ using, in the above example, either EST or EDT
    depending on the value of the date to be converted), but the problem
    is to know when to use EST and when to use EDT (or CET vs CEST, or CST
    vs CDT, MST vs MDT, &c.). The date on which the change happens is
    different in different time zones (e.g. compare CET#CEST vs EST#EDT).
    And I'd need this to be correct even though conventions on use of
    daylight savings times are subject to change (as in the US a year or
    two back).

    So, is there a package that you can recommend that handles this
    cleanly, or is there a database/flat data file that can be easily
    loaded into an RDBMS such as MySQL, PostgreSQL, MS SQL Server, that I
    could use to solve this? I have downloaded and installed a large
    number of time related packages using PPM (Activestate Perl 5.10.0 on
    Windows XP), but none of the ones I have examined address this
    particular issue. I am so frustrated in my search on this that until
    I find an adequate solution, the policy we've adopted is to put the
    onus on the client to tell us whether or not he wants reports using
    daylight savings times, and if so, when the transitions to and from
    daylight savings time happens. I would be grateful if someone could
    point me to an option that is more user friendly.

    Thanks

    Ted
    Ted Byers, Nov 6, 2008
    #1
    1. Advertising

  2. Ted Byers

    J. Gleixner Guest

    Ted Byers wrote:
    > NB: I have seen information about using the system's settings, but
    > that is not relevant to this problem.


    Could the subject be a little longer???

    >
    > I have a number of DB tables that have datetime values defined WRT UTC
    > time. If all users could/would work with UTC, there'd be no problem.
    > I have stored, in a users table, the users' specific timezones. So
    > far so good. I can use Date::Manip to convert from UTC to each user's
    > timezone easily. That is great!
    >
    > However, in many localities, there is a need to switch to and from a
    > daylight savings time, and I can use the time zones defined in
    > Date::Manip to specify which users would be using daylight savings

    [...]

    It's saving daylight, so there's only one 's' in daylight saving time.

    Lots of help/discussions/people who can help at:

    http://datetime.perl.org/
    J. Gleixner, Nov 6, 2008
    #2
    1. Advertising

  3. [A complimentary Cc of this posting was sent to
    Ted Byers
    <>], who wrote in article <>:
    > However, in many localities, there is a need to switch to and from a
    > daylight savings time, and I can use the time zones defined in
    > Date::Manip to specify which users would be using daylight savings
    > time, but the problem is that using something like "EST5EDT" in either
    > $from or $to Date_ConvTZ($date1,$from,$to1); does nothing (i.e. the
    > value returned is identical to $date1). In some respects, I was not
    > very surprised: unless there was some kind of database hidden in the
    > bowels of Date::Manip, it couldn't know when to switch to or from
    > daylight savings time based on the value of $date1.


    There is a notion of "timezone". A timezone uniquely determines the
    mapping GMT --> local time. "EST5EDT" is not a timezone.

    E.g., on this computer, I do

    >echo $TZ

    US/Pacific

    It is a function of kernel/CRT library to have a database of
    timezones. On capable systems, you should do

    $ENV{TZ} = 'US/Pacific';
    POSIX::settz(); # sp? tzset()?
    print scalar localtime time;

    and get the correct local time.

    Hope this helps,
    Ilya
    Ilya Zakharevich, Nov 7, 2008
    #3
  4. Ted Byers

    Ted Byers Guest

    On Nov 6, 8:25 pm, Ilya Zakharevich <> wrote:
    > [A complimentary Cc of this posting was sent to
    > Ted Byers
    > <>], who wrote in article <>:
    >
    > > However, in many localities, there is a need to switch to and from a
    > > daylight savings time, and I can use the time zones defined in
    > > Date::Manip to specify which users would be using daylight savings
    > > time, but the problem is that using something like "EST5EDT" in either
    > > $from or $to Date_ConvTZ($date1,$from,$to1); does nothing (i.e. the
    > > value returned is identical to $date1).  In some respects, I was not
    > > very surprised: unless there was some kind of database hidden in the
    > > bowels of Date::Manip, it couldn't know when to switch to or from
    > > daylight savings time based on the value of $date1.

    >
    > There is a notion of "timezone".  A timezone uniquely determines the
    > mapping GMT --> local time.  "EST5EDT" is not a timezone.
    >

    True. But Date::Manip uses it as a convention for indicating that the
    machine uses both EST and EDT. It works OK when I am working on times
    relevant to my local machine. But my current problem is that the
    times in question are stored in a database in UTC times, and really
    have nothing to do with the timezone that applies to the server
    running the DB. It is in the midwest US while the institution that is
    the source of the data is in central Europe and we have clients on,
    for example, the west coast of the US.

    > E.g., on this computer, I do
    >
    >    >echo $TZ
    >    US/Pacific
    >
    > It is a function of kernel/CRT library to have a database of
    > timezones.  On capable systems, you should do
    >
    >    $ENV{TZ} = 'US/Pacific';
    >    POSIX::settz();                      # sp?  tzset()?
    >    print scalar localtime time;
    >
    > and get the correct local time.
    >
    > Hope this helps,
    > Ilya



    What you suggest is applicable to various tasks on my own machine, but
    actually I already have that working already. My problem involves
    converting times that apply to one institution on the other side of
    the planet into timezones that are on the other side of this
    continent. I don't see how working wih my own local time helps.

    Thanks anyway Ilya
    Ted Byers, Nov 7, 2008
    #4
  5. Ted Byers

    Ted Byers Guest

    On Nov 6, 5:13 pm, "J. Gleixner" <>
    wrote:
    > Ted Byers wrote:
    > > NB: I have seen information about using the system's settings, but
    > > that is not relevant to this problem.

    >
    > Could the subject be a little longer???
    >


    I could try to get it longer, but my fingers would get too tired. ;-)
    >
    >
    > > I have a number of DB tables that have datetime values defined WRT UTC
    > > time.  If all users could/would work with UTC, there'd be no problem.
    > > I have stored, in a users table, the users' specific timezones.  So
    > > far so good.  I can use Date::Manip to convert from UTC to each user's
    > > timezone easily.  That is great!

    >
    > > However, in many localities, there is a need to switch to and from a
    > > daylight savings time, and I can use the time zones defined in
    > > Date::Manip to specify which users would be using daylight savings

    >
    > [...]
    >
    > It's saving daylight, so there's only one 's' in daylight saving time.
    >
    > Lots of help/discussions/people who can help at:
    >
    > http://datetime.perl.org/


    OK Thanks. I'll take a look there and see what progress I can make.

    Thanks

    Ted
    Ted Byers, Nov 7, 2008
    #5
  6. Ted Byers

    Dr.Ruud Guest

    Re: determine when to change to or from daylight savings time

    Ted Byers schreef:
    > Ilya Zakharevich:


    >> $ENV{TZ} = 'US/Pacific';
    >> POSIX::settz(); # sp? tzset()?
    >> print scalar localtime time;
    >>
    >> and get the correct local time.

    >
    > What you suggest is applicable to various tasks on my own machine, but
    > actually I already have that working already. My problem involves
    > converting times that apply to one institution on the other side of
    > the planet into timezones that are on the other side of this
    > continent. I don't see how working wih my own local time helps.


    Huh? Just put a different timezone string in $ENV{TZ}, right?

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Nov 7, 2008
    #6
  7. Ted Byers

    Peter Wyzl Guest

    Re: determine when to change to or from daylight savings time

    "Dr.Ruud" <> wrote in message
    news:...
    > Ted Byers schreef:
    >> Ilya Zakharevich:

    >
    >>> $ENV{TZ} = 'US/Pacific';
    >>> POSIX::settz(); # sp? tzset()?
    >>> print scalar localtime time;
    >>>
    >>> and get the correct local time.

    >>
    >> What you suggest is applicable to various tasks on my own machine, but
    >> actually I already have that working already. My problem involves
    >> converting times that apply to one institution on the other side of
    >> the planet into timezones that are on the other side of this
    >> continent. I don't see how working wih my own local time helps.

    >
    > Huh? Just put a different timezone string in $ENV{TZ}, right?


    Yes but is there some 'authorative source' of what all the different
    timezones are and the daylight times for those zones and when they switch
    back and forth?

    P
    Peter Wyzl, Nov 7, 2008
    #7
  8. Re: determine when to change to or from daylight savings time

    Peter Wyzl wrote:
    > is there some 'authorative source' of what all the different
    > timezones are and the daylight times for those zones and when they
    > switch back and forth?
    >


    Since those things are a matter of political whim I doubt there is a
    source I would be happy labelling authoritative for the whole planet.

    Try
    http://www.twinsun.com/tz/tz-link.htm

    --
    RGB
    RedGrittyBrick, Nov 7, 2008
    #8
  9. Ted Byers

    Dr.Ruud Guest

    Re: determine when to change to or from daylight savings time

    Peter Wyzl schreef:

    > but is there some 'authorative source' of what all the different
    > timezones are and the daylight times for those zones and when they
    > switch back and forth?


    I use DateTime::TimeZone which uses Olson. Good enough for me.
    http://search.cpan.org/search?query=timezone&mode=module

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Nov 7, 2008
    #9
  10. Ted Byers

    Guest

    Re: determine when to change to or from daylight savings time

    On Fri, 07 Nov 2008 10:51:46 +0000, RedGrittyBrick <> wrote:

    >
    >Peter Wyzl wrote:
    >> is there some 'authorative source' of what all the different
    >> timezones are and the daylight times for those zones and when they
    >> switch back and forth?
    >>

    >
    >Since those things are a matter of political whim I doubt there is a
    >source I would be happy labelling authoritative for the whole planet.
    >
    >Try
    >http://www.twinsun.com/tz/tz-link.htm


    Its the alias for $GOD

    sln
    , Nov 7, 2008
    #10
  11. Ted Byers

    Ted Byers Guest

    Re: determine when to change to or from daylight savings time

    On Nov 7, 3:05 am, "Dr.Ruud" <> wrote:
    > Ted Byers schreef:
    >
    > > Ilya Zakharevich:
    > >> $ENV{TZ} = 'US/Pacific';
    > >> POSIX::settz(); # sp? tzset()?
    > >> print scalar localtime time;

    >
    > >> and get the correct local time.

    >
    > > What you suggest is applicable to various tasks on my own machine, but
    > > actually I already have that working already.  My problem involves
    > > converting times that apply to one institution on the other side of
    > > the planet into timezones that are on the other side of this
    > > continent.  I don't see how working wih my own local time helps.

    >
    > Huh? Just put a different timezone string in $ENV{TZ}, right?
    >
    > --
    > Affijn, Ruud
    >
    > "Gewoon is een tijger."


    Actually no. This is to interact with a database on a server that
    serves a web application. Messing with the environment settings on
    the server for the timezone is guaranteed to fail. For example, there
    could be simultaneous requests for data applicable to different
    locations. Something like the function Date_ConvTZ($date,$from,$to)
    in Date::Manip is required instead but which would make use of the
    olson database you mentioned in another post to know when either
    timezone should use daylight saving time.

    Since you said you use DateTime::TimeZone, can you tell me an example
    of how to use it to take a date that, say, ParseDate($string), from
    Date::Manip, would return and convert it from one timezone to another
    using Olson's database to taking daylight saving time into account (in
    effect making something like Date_ConvTZ that would work with the
    EST5EDT that Date::Manip uses in other functions).

    Thanks

    Ted
    Ted Byers, Nov 7, 2008
    #11
  12. Ted Byers

    Ted Byers Guest

    Re: determine when to change to or from daylight savings time

    On Nov 7, 6:39 am, wrote:
    > On Fri, 07 Nov 2008 10:51:46 +0000, RedGrittyBrick <> wrote:
    >
    > >Peter Wyzl wrote:
    > >> is there some 'authorative source' of what all the different
    > >> timezones are and the daylight times for those zones and when they
    > >> switch back and forth?

    >
    > >Since those things are a matter of political whim I doubt there is a
    > >source I would be happy labelling authoritative for the whole planet.

    >
    > >Try
    > >http://www.twinsun.com/tz/tz-link.htm

    >
    > Its the alias for $GOD
    >
    > sln


    That gives you the olson data that Dr Ruud mentioned. I have
    downloaded that and am presently trying to figure out how to use it.
    found a couple scripts in the timezone project: parse_olson and
    update_from_latest_olson. I can't use the latter since it is written
    explicitly using programs and paths found on Unix and not, normally,
    on Windows, but parse_olson looks like it may work for me. I'll know
    later today if it does. But I am still looking through the
    documentation for DateTime::TimeZone to see how to use it to convert,
    e.g., a time from UTC to "EST5EDT" (as defined in Date::Manip), using
    either EST or EDT on the right dates.

    Thanks

    Ted
    Ted Byers, Nov 7, 2008
    #12
  13. Re: determine when to change to or from daylight savings time

    "Peter Wyzl" <> wrote:
    >Yes but is there some 'authorative source' of what all the different
    >timezones are and the daylight times for those zones and when they switch
    >back and forth?


    Impossible. If it were by country then at least you would have a chance.
    But there are so many special rules and exceptions, in particular in the
    US where even individual counties deviate from their state, not to
    mention indian reservations that do or do not, etc, etc. It's just plain
    a mess.

    jue
    Jürgen Exner, Nov 7, 2008
    #13
  14. Re: determine when to change to or from daylight savings time

    [A complimentary Cc of this posting was sent to
    Peter Wyzl
    <>], who wrote in article <N3UQk.11775$>:
    > >> What you suggest is applicable to various tasks on my own machine, but
    > >> actually I already have that working already. My problem involves
    > >> converting times that apply to one institution on the other side of
    > >> the planet into timezones that are on the other side of this
    > >> continent. I don't see how working wih my own local time helps.

    > >
    > > Huh? Just put a different timezone string in $ENV{TZ}, right?

    >
    > Yes but is there some 'authorative source' of what all the different
    > timezones are and the daylight times for those zones and when they switch
    > back and forth?


    As I said, your kernel/CRTL should already contain such a database. I
    would try to follow links starting with

    man tzset

    to find a way to query the names of the zones...

    Hope this helps,
    Ilya
    Ilya Zakharevich, Nov 7, 2008
    #14
  15. Ted Byers

    Peter Wyzl Guest

    Re: determine when to change to or from daylight savings time

    "Ilya Zakharevich" <> wrote in message
    news:gf250o$1bnc$...
    > [A complimentary Cc of this posting was sent to
    > Peter Wyzl
    >>
    >> Yes but is there some 'authorative source' of what all the different
    >> timezones are and the daylight times for those zones and when they switch
    >> back and forth?

    >
    > As I said, your kernel/CRTL should already contain such a database. I
    > would try to follow links starting with
    >
    > man tzset
    >
    > to find a way to query the names of the zones...


    If I wasn't one of the large % of users who don't have a kernel as such,
    that might be helpful.

    P
    Peter Wyzl, Nov 7, 2008
    #15
  16. Ted Byers

    Ted Byers Guest

    Re: determine when to change to or from daylight savings time

    On Nov 7, 6:26 am, "Dr.Ruud" <> wrote:
    > Peter Wyzl schreef:
    >
    > > but is there some 'authorative source' of what all the different
    > > timezones are and the daylight times for those zones and when they
    > > switch back and forth?

    >
    > I use DateTime::TimeZone which uses Olson. Good enough for me.http://search.cpan.org/search?query=timezone&mode=module
    >
    > --
    > Affijn, Ruud
    >
    > "Gewoon is een tijger."


    I have downloaded the Olson timezone data, and executed the script
    "parse-olson.pl". It created a directory called lib that contains the
    timezone data transformed into *.pm files in a number of directories.
    I have perl installed in C:\Perl. Do I just copy the files and
    folders created by parse_olson.pl into C:\Perl\site, over-writing
    what's already there?

    Thanks

    Ted
    Ted Byers, Nov 8, 2008
    #16
  17. Re: determine when to change to or from daylight savings time

    [A complimentary Cc of this posting was sent to
    Peter Wyzl
    <>], who wrote in article <o24Rk.12858$>:

    > If I wasn't one of the large % of users who don't have a kernel as such,


    And who do you think runs your Perl? Maybe the BIOS? ;-)

    Anyway, POSIX::tzset will run tzset() function of the CRTL of (your?)
    compiler. Its documentation may also contain a list...

    (But probably tzset() is very crippled on Win*...)

    Yours,
    Ilya
    Ilya Zakharevich, Nov 8, 2008
    #17
  18. Re: determine when to change to or from daylight savings time

    On Sat, 8 Nov 2008 09:09:29 +0000 (UTC),
    Ilya Zakharevich <> wrote:
    > [A complimentary Cc of this posting was sent to
    > Peter Wyzl
    ><>], who wrote in article
    ><o24Rk.12858$>:
    >
    >> If I wasn't one of the large % of users who don't have a kernel as such,

    >
    > And who do you think runs your Perl? Maybe the BIOS? ;-)
    >
    > Anyway, POSIX::tzset will run tzset() function of the CRTL of (your?)
    > compiler. Its documentation may also contain a list...


    THis is the second time you've used the (presumably) acronym CRTL. What
    exactly do you mean by that? I don't know the term, and Google,
    Wikipedia freedictionary and the hacker's dictionary also don't seem to
    help.

    Martien
    --
    |
    Martien Verbruggen | Make it idiot proof and someone will make a
    | better idiot.
    |
    Martien Verbruggen, Nov 8, 2008
    #18
  19. Re: determine when to change to or from daylight savings time

    On Sat, 08 Nov 2008 21:13:54 +1100, Martien Verbruggen wrote:

    > THis is the second time you've used the (presumably) acronym CRTL. What
    > exactly do you mean by that? I don't know the term, and Google,
    > Wikipedia freedictionary and the hacker's dictionary also don't seem to
    > help.


    C RunTime Library, aka CRT.

    M4
    Martijn Lievaart, Nov 8, 2008
    #19
  20. Ted Byers

    Dr.Ruud Guest

    Re: determine when to change to or from daylight savings time

    Ted Byers schreef:
    > Dr.Ruud:
    >> Peter Wyzl:


    >>> but is there some 'authorative source' of what all the different
    >>> timezones are and the daylight times for those zones and when they
    >>> switch back and forth?

    >>
    >> I use DateTime::TimeZone which uses Olson. Good enough for
    >> me.http://search.cpan.org/search?query=timezone&mode=module

    >
    > I have downloaded the Olson timezone data, and executed the script
    > "parse-olson.pl". It created a directory called lib that contains the
    > timezone data transformed into *.pm files in a number of directories.
    > I have perl installed in C:\Perl. Do I just copy the files and
    > folders created by parse_olson.pl into C:\Perl\site, over-writing
    > what's already there?


    I have no clue what you are trying to achieve, or rather mess up, so I
    can't anwer that question.
    But if you want to install specific Perl modules on a Windows system in
    a clean way, just use the latest ActiveState or the Vanilla Perl tools.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Nov 9, 2008
    #20
    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. feng
    Replies:
    0
    Views:
    313
  2. Brian Henry
    Replies:
    0
    Views:
    352
    Brian Henry
    Jul 28, 2005
  3. Roy G. Vervoort

    determin color of a specific hyperlink

    Roy G. Vervoort, Feb 2, 2004, in forum: HTML
    Replies:
    31
    Views:
    2,478
    Mark Parnell
    Feb 9, 2004
  4. crjunk
    Replies:
    1
    Views:
    387
    crjunk
    Sep 25, 2006
  5. sin kanti
    Replies:
    2
    Views:
    87
    Wesley J. Landaker
    Apr 10, 2005
Loading...

Share This Page