FAQ

my $dt1 = DateTime->new(
year => 2014,
month => 3,
day => 30,
hour => 3,
minute => 30,
second => 0,
time_zone => 'Europe/Kiev',);

return an error "Invalid local time for date in time zone: Europe/Kiev".

My problem:
I have datetime, stored in "UTC" and have some periodical task (period 1 day). Then i have a customer - for him information must be viewed in 'Europe/Kiev'. In this timezone present DST.
So customer see time of execution task (in his timezone) for example:
00:03:30
00:03:30
00:03:30
(then we have DST)
00:04:30
00:04:30
00:04:30
00:04:30
But he want that task will execute in 00:03:30 in his local timezone. Please help me solve this problem.
Thank you in advance.

Search Discussions

  • Zefram at May 8, 2014 at 1:37 pm

    my $dt1 = DateTime->new(
    year => 2014,
    month => 3,
    day => 30,
    hour => 3,
    minute => 30,
    second => 0,
    time_zone => 'Europe/Kiev',);

    return an error "Invalid local time for date in time zone: Europe/Kiev".
    The error message is correct: there is no 03:30 in Kiev time on
    2014-03-30. Kiev switched from UT+2h to UT+3h at 01:00 UT, jumping from
    02:59 to 04:00 local time.
    I have datetime, stored in "UTC" and have some periodical task (period 1 day). Then i have a customer - for him information must be viewed in??'Europe/Kiev'.
    This part is no problem. Each UT time corresponds to a definite Kiev
    local time; you can always perform this conversion. The code that you
    quoted doesn't perform conversion; you need to create a DateTime with
    time_zone=>"UTC" and then set_time_zone.
    But he want that task will execute in 00:03:30 in his local timezone.
    Presuming you mean at 03:30, this is not possible for Kiev on 2014-03-30.
    In general, it is not possible to do something at a fixed local time
    every day; there's always some day and locality for which that local
    time doesn't exist. In the extreme, there are cases such as Christmas
    Island (Pacific/Kiritimati) on 1995-01-01, where local time skipped the
    entire calendar day as the island switched from the eastern side of the
    International Date Line to the more fashionable western side.

    You must select some alternative behaviour to follow on days when the
    desired local time doesn't exist.

    -zefram

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdatetime @
categoriesperl
postedMay 7, '14 at 2:59p
activeMay 8, '14 at 1:37p
posts2
users2
websitemetacpan.org...

2 users in discussion

Андрей: 1 post Zefram: 1 post

People

Translate

site design / logo © 2019 Grokbase