Ruby on Rails Tuesday, August 31, 2010

reu wrote:
> Rails automatically appends a dummy date when you use the TIME type on
> your database. My point is: if you are using a time data type on your
> database, you are doing that exactly because you don't want the date
> included.
>
> Anyway, I am storing a integer column with the total seconds on the
> database and then transforming that with composed_of. Is there a
> better way to do that? Anyone know if there is a gem or something to
> handle cases like these?

Time without data is useless and extremely prone to error. Internally
time is stored as millisecond offsets from a reference date (e.g. UNIX
time is the number of milliseconds from midnight January 1, 1970 UTC).
The date and time related objects in Ruby depend on this underlying
offset.

a value of 14:00 is meaningless without relating that to some date, in
some time zone, and applying the geopolitical rules for daylight savings
(or other adjustments to the normal flow of time).

I personally don't know why MySQL even bothers providing a TIME field
type.

Of course, as always, I could be missing some specific use case for it.
--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment