Determining the time at which a date starts

Viewed 2923

Say I want to create a daily planner, and I want to divide the day into 15 minute chunks.

Easy, right? Just start at midnight, and... Wrong! In America/Sao_Paulo, one day each year starts at 01:00 because of Daylight Saving Time changes.

Given a time zone and a date, how does one find the epoch time at which the day starts?

My first thought was to use the following, but it assumes each day has a 23:59. That's probably no better of an assumption than assuming each day has a midnight.

perl -MDateTime -E'
   say
      DateTime->new( year => 2013, month => 10, day => 20 )
      ->subtract( days => 1 )
      ->set( hour => 23, minute => 59 )
      ->set_time_zone("America/Sao_Paulo")
      ->add( minutes => 1 )
      ->strftime("%H:%M");
'
01:00

Is there a more robust or more direct alternative?

7 Answers
Related