From: Xeno Campanoli Date: 2009-06-11T10:19:15+09:00 Subject: Re: Is there a decent canonical way to get total days in a month from say Time class? Xeno Campanoli wrote: > I suppose I could flip through local until I generate an exception, but > somehow I would think there would be a set of class methods to get: Here's a fairly simple sequence I found on the net using Date (attributions to kelyar, jgwong, and timmorgan, whoever they are): #!/usr/bin/ruby # require 'date' d0 = Date.new(2009,6,1) puts "trace d0: #{d0}" d1 = d0 >> 1 puts "trace d1: #{d1}" d2 = d1 - 1 puts "trace d2: #{d2}" d3 = d2.day puts "trace d3: #{d3}" ---snip--- the above are my own illustration of what the authors show in their blog posts. > > daysofmonth = Time.daysofmonth(y,m) > daysofyear = Time.daysofyear(y) > leapday = Time.leapday?(y) > leapseconds = Time.leapseconds?(y) > > ?? > xc > >