[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Calculate last day of month

Gavin Kistner

9/21/2006 8:32:00 PM

From: Norgg [mailto:xennocide@yahoo.com]
> Slightly nicer is:
> puts Date.new(2006, 9, -1)
> #2006-09-30

Well, aren't you Mr. Tricky? :)

Here's the documentation For Date.civil() describing the feature Norgg
describes:

"Create a new Date object for the Civil Date specified by year y, month
m, and day-of-month d.

m and d can be negative, in which case they count backwards from the end
of the year and the end of the month respectively. No wraparound is
performed, however, and invalid values cause an ArgumentError to be
raised."

1 Answer

Ara.T.Howard

9/21/2006 9:05:00 PM

0