Re: Error with the leap year

[email protected] (Michael G Schwern)
Newsgroups perl.datetime
Message-ID <[email protected]>
On 2012.3.2 11:17 AM, Dave Rolsky wrote:
> However, I will point out that what you were doing is weird. If you want to do
> DateTime math, you need to use ->add and ->subtract (although these can _also_
> come up with invalid datetimes in the face of DST changes). The DST issue is
> documented pretty clearly in the "How Datetime Math Works" section of the docs.

While there may be a section about DateTime math, there's little in the docs
about set caveats.  It's non-obvious that $dt->set_year( $dt->year + 1 ) is
significantly different than $dt->add( years => 1 ) or that there's anything
wrong with using set in that manner.  There needs to be a warning or pointer
in the set docs, because a user has no motivation to fish further.

I'd suggest a section about when to use set_* and when to use add_* and what
their caveats are.  Put pointers to it in the set_* and add_* documentation.


-- 
10. Not allowed to purchase anyone's soul on government time.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/
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.