On Sun, Jul 12, 2009 at 6:15 AM, Frederick Cheung<[email protected]> wrote: > > On Jul 12, 4:09 am, Josh <[email protected]> wrote: >> >> After looking into conversions.rb. It appears that rails thinks of >> time as a datetime and this doesn't seem proper, especially when Date >> does not. Why should a random date be assigned to the time? >> >> I'll happily make a patch, but I thought to ask if there was some sort >> of reasoning behind this, or a special circumstance I will destroy >> when allowing to a Time hash conversion like Date has, which is >> independent of datetime? > > The root of the issue is that there is no pure time of day class in > ruby (which is why Time is used). Maybe the right thing to do would be > to write such a class (although you'd have a large backwards > compatibility task).
Right. Ruby Time and DateTime instances both represent a point in time (which includes the date). They vary mostly in internal representation. DateTIme has a broader range that it can represent, since TIme uses the underlying C library time data structures and has a platform dependent earliest and latest value. ActiveSupport has a Duration class, which is closer to something like the time interval which the OP seems to be seeking. But Duration is really used only to represent a value to be added/subtracted from a Time/Date time. It's what you get when you evaluate an expression like 1.second, 1.hour, or (1.second + 1.hour). And it normally comes into play in an expressions like Time.now + 1.day or 1.week.from_now -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

