Re: Seconds left in day + DST

[email protected] (Jost Krieger)
Newsgroups perl.datetime
Message-ID <[email protected]>
On Fri, Jun 20, 2008 at 11:07:47AM +0200, Dr.Ruud wrote:
> Rick Measham schreef:
> > P DD wrote:
> 
> >> my $tom = ($now + DateTime::Duration->new(days => 1))->
> >> truncate(to => 'day');
> > 
> > Can I suggest this for neater code:
> > my $tom = $dt->clone->add( days => 1 )->truncate( to => 'day' );
> 
> I seem to remember that adding 24 hours is safer than adding 1 day. 
> (to never land on a non-existing DT value)

Then
  my $tom = $dt->clone->truncate( to => 'day' )->add( days => 1 );
should be yet safer, in case you call it during a leap second ;-)

Unless someone messes with the first second of a day, that is.

Jost
-- 
| Helft Spam ausrotten!                HTML in Mail ist unhöflich. |
| Postmaster, JAPH, manchmal Wahrsager               am RZ der RUB |
| Wahre Worte sind nicht gefällig, gefällige Worte sind nicht wahr.|
|                                          Lao Tse, Tao Te King 81 |
smime.p7s (application/pkcs7-signature, 2 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.