class Time def Time.validate(year, month=1, day=1, hour=0, min=0, sec=0, usec=0) require "date" begin d = Date.new(year,month,day) rescue return nil end Time.local(year,month,day,hour,min,sec,usec) end end t1 = Time.validate(2000,11,30) # Instantiates a valid object t2 = Time.validate(2000,11,31) # Returns nil