I just use a datetime column and ignore the date part.
Colin
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/.
Correction: Time without date...
Repeating events, "Tuesdays at 4:00pm" for example.
PostgreSQL also provides a time field type where no date is stored.
--
Greg Donald
destiney.com | gregdonald.com
As I said meaningless without applying the date part to it. If today is
Saturday, and the event is scheduled at 4:00 p.m. Tuesday, what happens
if the time changes to, or from, daylight savings time at 2:00 a.m.
Sunday. The value "4:00 p.m." must be translated based on the specific
date the Tuesday lands on. Might as well just store the time as a string
at that point. The time has no value as a Time (object) (i.e it must be
parsed based on the date anyway).
I suppose though that the TIME field would provide some basic
validation, which would be it's only benefit as far as I see it.
If I have a date at 4pm on Tuesday, the date is at 4pm regardless of
the state of daylight savings time :-)
In what time zone?
Hopefully she'll be in the same as me wherever it is, otherwise it
probably won't be a very good date.
But, if there is a risk in the implementation that timezones confusion
could cause problems, then store a timezone value in addition to the
time. There's not that much more confusion with timezones caused when
storing just time than with datetime.
My point being again that any interpretation of whatever gets stored as
a time only, must be translated into a Time or DateTime object based on
a specific date, in a specific locale. That's really all I'm saying.
4:00 p.m. from your locale may mean 7:30 p.m. in my locale. It's
dependent on geopolitical rules.
Not all apps require multi-timezone capabilities. Like when everyone
is in one office, using the same calendar app.
Dreaming up edge cases isn't going to make those time (without date)
fields any less useful to those of us who use them.
Lots of web apps, certainly dozens I've built, are just for a single
company, with a single office, in a single time zone.
That's great that you build apps where time zone does matter, and that
you build apps for companies where time zone does matter, but it
doesn't make the time (without date) field any less useful to me.
You're still missing my point entirely. We're talking about representing
a time with a Time object. It matters not whether you need to support
multi-timezone or not. AFAIK there is no Ruby object that represents
time without date. The Time object represents an instant in date/time,
not some offset from midnight.
I hope that makes my meaning more clear.
I agree, you brought it up.
> AFAIK there is no Ruby object that represents
> time without date.
It's called a Fixnum, works great.
Yep. I apologize for the misunderstanding. I knew we were arguing the
same side of the issue. It just took me a few tries to get to the heart
of the matter.
Fixnum (INTEGER) is exactly what I typically use as well (i.e. an offset
from midnight).
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.
My original intent was an effort to explain this question in original
post. Rails is applying a "dummy date" because it must. However, that
time representation is subject to interpretation. And that depends on
what time zone Rails applies to that interpretation.
Just for the sake of argument... how about the time it takes runners to finish a marathon? Sure you could use seconds as an integer field, but time without date make sense...
I agree that "4pm" is kind of pointless, but "16 hours" can be handy.
If only to save me from having to convert from seconds to hh:mm:ss and back, etc...
-philip
Just for the sake of argument... how about the time it takes runners to finish a marathon? Sure you could use seconds as an integer field, but time without date make sense...
I agree that "4pm" is kind of pointless, but "16 hours" can be handy.
If only to save me from having to convert from seconds to hh:mm:ss and back, etc...
-philip
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/-8Y1pxABBnAJ.
For more options, visit https://groups.google.com/groups/opt_out.