A day without midnight

There are several. As of 2020-04, there are 14 such time zones in 10 countries: Paraguay, Cuba, Chile, Greenland/Denmark, Jordan, Lebanon, Syria, Palestine, Iran, and Azores/Portugal.

Before 2019-04, the list included Brazil using the America/Sao_Paulo time zone.

$ perl -MDateTime -E'say DateTime->new(
     year => 2013, month => 10, day => 20, hour => 12,
     time_zone => "America/Sao_Paulo")->truncate( to => "day" )->ymd;'
Invalid local time for date in time zone: America/Sao_Paulo

You can get around the problem by switching to the “floating” tome zone before getting the date:

$ perl -MDateTime -E'say DateTime->new(
     year => 2013, month => 10, day => 20, hour => 12,
     time_zone => "America/Sao_Paulo")
   ->set_time_zone("floating")
   ->truncate( to => "day" )
   ->ymd;'
2013-10-20

See this documentation.

Leave a Comment