From: Paul Lutus Date: 2006-10-27T06:20:16+09:00 Subject: Re: Time without Date List Recv wrote: > Is there any class or lib to deal with Times without Date? (Eg "3:30 > PM" - but I don't want it associated with a date.) > > Ideally, I'd like to: > * Have clock arithmetic (1 AM minus 90 minutes is 11:30 PM) > * Convert from DateTime to dateless times (and, by adding a date, back) > * Store it with ActiveRecord > > Any ideas? Have you tried the Time class? #!/usr/bin/ruby -w is = Time.new h = 4 # hours was = is - (h * 60 * 60) puts "Time now: #{is}\nTime then: #{was}" Output: Time now: Thu Oct 26 14:10:41 PDT 2006 Time then: Thu Oct 26 10:10:41 PDT 2006 The Time object is expressed in seconds elapsed since 1/1/1970 00:00 GMT. Just add or subtract seconds to get what you want. And the 1970 limitation isn't actually much of a limitation: irb(main):008:0> t = Time.new - (100 * 60 * 60 * 24 * 365.25) => Fri Oct 26 13:16:52 PST 1906 -- Paul Lutus http://www.arachnoid.com