use Date.civil
With Date.civil(y, m, d)
or its alias .new(y, m, d)
, you can create a new Date object. The values for day (d) and month (m) can be negative in which case they count backwards from the end of the year and the end of the month respectively.
=> Date.civil(2010, 02, -1)
=> Sun, 28 Feb 2010
>> Date.civil(2010, -1, -5)
=> Mon, 27 Dec 2010
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…