sabbyxtabby
10/21/2003 4:30:00 PM
Emmanuel Touzery <emmanuel.touzery@wanadoo.fr> wrote:
> nobu.nokada@softhome.net wrote:
>
> >If you just want dates, what about date.rb?
> >
> > require 'date'
> > today = Date.today
> > today.to_s # => "2003-10-21"
> > (today+5).to_s # => "2003-10-26"
> >
> >I've not tested it with DST though.
>
> otherwise, yes it's probably what i want. unfortunately i now sit on a
> lot of code to convert :O(
> if someone has a way with Time, it would simplify things for me...
Here's half a solution:
class Time
require 'date'
DAY = 60*60*24
alias add +
def +(s)
return add(s) unless s % DAY == 0
d = Date.new(year, mon, day) + s / DAY
Time.local(d.year, d.mon, d.day, hour, min, sec, usec)
end
end