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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 31 August 2010 04:44, reu <rnavarro1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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?I just use a datetime column and ignore the date part. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker wrote:> 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.Correction: Time without date... -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Aug 31, 2010 at 1:46 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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.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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Donald wrote:> On Tue, Aug 31, 2010 at 1:46 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> 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. > > Repeating events, "Tuesdays at 4:00pm" for example. > > PostgreSQL also provides a time field type where no date is stored.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). -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker wrote:> 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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 31 August 2010 20:15, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Greg Donald wrote: > 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).If I have a date at 4pm on Tuesday, the date is at 4pm regardless of the state of daylight savings time :-) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> On 31 August 2010 20:15, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Greg Donald wrote: >> 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). > > > 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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Aug 31, 2010 at 2:21 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>> 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?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. -- Greg Donald destiney.com | gregdonald.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 31 August 2010 20:21, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>> 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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker wrote:>> 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?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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Aug 31, 2010 at 2:30 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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.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. -- Greg Donald destiney.com | gregdonald.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Donald wrote:> 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.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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Aug 31, 2010 at 2:41 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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.I agree, you brought it up.> AFAIK there is no Ruby object that represents > time without date.It''s called a Fixnum, works great. -- Greg Donald destiney.com | gregdonald.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > In what time zone? >To produce a specific part it takes our machine 1 hour and 15 minutes => 01:15:00 And I would like to store this value in the database. Btw it wouldn''t matter if this part will be produced on Mondays or Tuesdays or in which time zone the factory is.. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Donald wrote:> On Tue, Aug 31, 2010 at 2:41 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> 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. > > 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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> 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 date 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).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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom wrote in post #937228:> 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''m currently developing application, where I need to store beginning date (date only, without time) and amount of time passed. I found a gem, that deals with ''time without date'' issue: https://github.com/lailsonbm/time_of_day It can be useful in some cases. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Am Dienstag, 31. August 2010 23:12:51 UTC+2 schrieb 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 >So we have to differentiate between - "Time" which means Point of Time in a specific day, and - "Duration" which means the difference between two Points in Time Is there a "Duration" gem for RoR ? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Yes, check ActiveSupport, RoR has it. On Oct 26, 2012, at 10:34 PM, KlausG wrote:> Am Dienstag, 31. August 2010 23:12:51 UTC+2 schrieb 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 > > So we have to differentiate between > - "Time" which means Point of Time in a specific day, and > - "Duration" which means the difference between two Points in Time > > Is there a "Duration" gem for RoR ? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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. > >Best regards, Zhi-Qiang Lei zhiqiang.lei-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.