Happy (almost end) of April!

  $DateTime::VERSION = '0.77';
  $DateTime::Locale::VERSION = '0.45';
  $DateTime::TimeZone::VERSION = '1.46';

Can someone explain what's happening here?  Did April vanish?

My end goal is to get the start of the month in a specific timezone.

Here we are now:

$ perl -wle 'use DateTime; my $t = DateTime->now->set_time_zone(
"Asia/Amman" ); print $t'
2016-04-23T00:53:02

Why can't I truncate to the month?

$ perl -wle 'use DateTime; my $t = DateTime->now( time_zone => "Asia/Amman"
)->truncate( to => "month" ); print $t'
Invalid local time for date in time zone: Asia/Amman

Try a few days from now...

$ perl -wle 'use DateTime; my $t = DateTime->now( time_zone => "Asia/Amman"
)->add( days => 7)->truncate( to => "month" ); print $t'
Invalid local time for date in time zone: Asia/Amman


But add enough days to roll over to May:

$ perl -wle 'use DateTime; my $t = DateTime->now( time_zone => "Asia/Amman"
)->add( days => 8)->truncate( to => "month" ); print $t'
2016-05-01T00:00:00

Try going backwards:

$ perl -wle 'use DateTime; my $t = DateTime->now( time_zone => "Asia/Amman"
)->subtract( days => 22)->truncate( to => "month" ); print $t'
Invalid local time for date in time zone: Asia/Amman


And make it to march:

$ perl -wle 'use DateTime; my $t = DateTime->now( time_zone => "Asia/Amman"
)->subtract( days => 23)->truncate( to => "month" ); print $t'
2016-03-01T00:00:00

Some kind of April fool's issue?

Exists elsewhere in same offsets:

perl -wle 'use DateTime; my $t = DateTime->now( time_zone =>
"Asia/Tel_Aviv" )->subtract( days => 22)->truncate( to => "month" ); print
$t'
2016-04-01T00:00:00




-- 
Bill Moseley
mose...@hank.org

Reply via email to