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.