• DateTime::Format::ISO8601->parse_time

    From hymie!@21:1/5 to All on Mon Jan 4 01:41:14 2021
    Greetings.

    I'm a big fan of the DateTime modules, but I'm having some trouble with
    the DateTime::Format::ISO8601 parse_time() function.

    The problem I'm having is that I'm in UTC-0500 (US Eastern Time Zone) but
    the parse_time function assumes I'm working in UTC. So if the current date/time is 2021-01-03 20:00 in my local time zone, then parse_time is
    working off of a base of 2021-01-04 01:00 . Since parse_time does not
    take a date, only a time, then the resulting object is off by a day.

    I am aware that DateTime::Format::ISO8601->new() takes an optional "base_datetime" , but when I try to set this:

    $base = DateTime->now()->set_time_zone("America/New_York");

    $date = DateTime::Format::ISO8601 -> new ( base_datetime => $base )
    ->parse_time( "1955" );

    I end up in an infinite loop.

    brk(0x2808000) = 0x2808000
    brk(0x2829000) = 0x2829000
    brk(0x284a000) = 0x284a000
    brk(0x286b000) = 0x286b000
    brk(0x288c000) = 0x288c000
    brk(0x288b000) = 0x288b000
    brk(0x28ac000) = 0x28ac000
    brk(0x28cd000) = 0x28cd000
    brk(0x28ee000) = 0x28ee000
    brk(0x28ed000) = 0x28ed000
    [...]

    Is there something that I can do to force DateTime::Format::ISO8601's parse_time() function to do what I want -- use the local time zone as
    its base for the unspecified date?

    (Reminder, for those of you willing to test and help -- the problem only
    exists when the **current time** is between midnight-UTC and midnight-local, **not** the time provided to the parse_time function.)

    Thanks.

    --hymie! http://nasalinux.net/~hymie hymie@nasalinux.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From George Bouras@21:1/5 to All on Mon Jan 4 22:48:59 2021
    Στις 4/1/2021 3:41 π.μ., ο/η hymie! έγραψε:
    Greetings.

    I'm a big fan of the DateTime modules, but I'm having some trouble with
    the DateTime::Format::ISO8601 parse_time() function.


    maybe not what you want but it looks fine to me
    my ($YYYY,$MM,$DD,$HH,$MM,$SS) = ...
    =~/^(\d+4)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ or die "shit happens\n";

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hymie!@21:1/5 to who on Tue Jan 5 13:25:11 2021
    In our last episode, the evil Dr. Lacto had captured our hero,
    George Bouras <foo@example.com>, who said:
    Στις 4/1/2021 3:41 π.μ., ο/η hymie! έγραψε:
    Greetings.

    I'm a big fan of the DateTime modules, but I'm having some trouble with
    the DateTime::Format::ISO8601 parse_time() function.


    maybe not what you want but it looks fine to me
    my ($YYYY,$MM,$DD,$HH,$MM,$SS) = ...
    =~/^(\d+4)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ or die "shit happens\n";

    I'm sorry, but I honestly have no idea what you're trying to say here.

    --hymie! http://nasalinux.net/~hymie hymie@nasalinux.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to hymie@nasalinux.net on Tue Jan 5 16:13:08 2021
    hymie! <hymie@nasalinux.net> writes:

    I'm a big fan of the DateTime modules, but I'm having some trouble with
    the DateTime::Format::ISO8601 parse_time() function.

    The problem I'm having is that I'm in UTC-0500 (US Eastern Time Zone) but
    the parse_time function assumes I'm working in UTC.

    Juding from the documentation and a (somewhat cursory) look at the code,
    it should be possible to pass the local time zone as numeric offset
    appended to the time string, eg,

    20:00:00-05:00

    at least for parse_datetime.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)