From: ara.t.howard@... Date: 2006-10-27T12:50:03+09:00 Subject: Re: Time without Date On Fri, 27 Oct 2006, _Kevin wrote: > > List Recv wrote: >> Related question: >> >> Is there a way to convert a Time (or DateTime) to Ruby's Date class? > > I added a few conversion methods like this to 'ruby-units' gem > > class Time > def to_datetime > DateTime.civil(1970,1,1)+(self.to_f+self.gmt_offset)/86400 > end > > def to_date > Date.civil(1970,1,1)+(self.to_f+self.gmt_offset)/86400 > end > end > > This seems to work pretty well, although I haven't tested it on a wide > range of OSs. it's nice to have Time.to_time Time.to_date Date.to_time Date.to_date DateTime.to_time DateTime.to_date so you can do do_not_care_which_one.to_time do_not_care_which_one.to_date a la rails. 2 cts. -a -- my religion is very simple. my religion is kindness. -- the dalai lama