I want to save the time that is needed to complete a task I would like to save hours and minutes, after filling a form. So I need a select tag, but I am not able to use select_time the way way I want. By default, it gives me the present time, and I would like to have two selects that begin with ''00''. After filling the gap, shoud I save this like a timestamp? So I would like to know what is the best to use in the form and how to save it. I''ll appreciate any help. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Charles Johnson
2009-Mar-12 20:43 UTC
Re: Which is the best way to do this? (about save time data)
On Thu, Mar 12, 2009 at 2:39 PM, John Smith < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I want to save the time that is needed to complete a task I would like > to save hours and minutes, after filling a form. So I need a select tag, > but I am not able to use select_time the way way I want. By default, it > gives me the present time, and I would like to have two selects that > begin with ''00''. > After filling the gap, shoud I save this like a timestamp? > > So I would like to know what is the best to use in the form and how to > save it. I''ll appreciate any help.Have you looked at select_hour and select_minute, specifically select_hour(0) and select_minute(0)? How it gets depends on what data you need. Do you know the date the task was started? Do you need to know the date the task was completed? Do you just need to know that for task "A" it was worked on for 3 hours and 10 minutes (say)? Cheers-- Charles --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
John Smith
2009-Mar-13 13:00 UTC
Re: Which is the best way to do this? (about save time data)
I think that select_hour(0) and select_minute(0) it''s what I need. I just want to save the time it''s needed to complete a task, so I only need to select and hour and minutes. How should I save this? Like a string or like a datetime? I think it would b better datetime, because I want to search by this time. But then I think I should need to create a datetable using two fields, select_hour and select_minute. Is it correct? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Charles Johnson
2009-Mar-13 13:21 UTC
Re: Which is the best way to do this? (about save time data)
On Fri, Mar 13, 2009 at 8:00 AM, John Smith < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I think that select_hour(0) and select_minute(0) it''s what I need. I > just want to save the time it''s needed to complete a task, so I only > need to select and hour and minutes. How should I save this? Like a > string or like a datetime? I think it would b better datetime, because I > want to search by this time. But then I think I should need to create a > datetable using two fields, select_hour and select_minute. Is it > correct? > -- >As I said, this depends on what you are wanting to record. For me, if I were interested in something like "On this date I worked on task-1 for 3 hours and 37 minutes, and task-2 for 2 hours and 7 minutes" I would be recording a date, and then I would convert "hours" and "minutes" to just minutes (3 hours and 37 minutes = 217 minutes) and save the date and the total minutes. All of the Date, DateTime, and Time objects in ruby are related to a calendar, i.e., the want a date and a specific time, not a date and a duration, which seems to me what you are after. Make sense? Cheers-- Charles --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
John Smith
2009-Mar-13 16:27 UTC
Re: Which is the best way to do this? (about save time data
Thanks for your help, Charles. I appreciate it. What I want is the duration needed to complete a specific task. So when I have a lot of tasks, I will be able to search tasks width its durations is bigger that 2 hours and 10 minutes, for example. I don''t care about days, monts of yearsM I only need the duration. So, should I use a Datetime in order to make search easy? Again, thanks a lot. Charles Johnson wrote:> On Fri, Mar 13, 2009 at 8:00 AM, John Smith < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> >> I think that select_hour(0) and select_minute(0) it''s what I need. I >> just want to save the time it''s needed to complete a task, so I only >> need to select and hour and minutes. How should I save this? Like a >> string or like a datetime? I think it would b better datetime, because I >> want to search by this time. But then I think I should need to create a >> datetable using two fields, select_hour and select_minute. Is it >> correct? >> -- >> > As I said, this depends on what you are wanting to record. For me, if I > were > interested in something like "On this date I worked on task-1 for 3 > hours > and 37 minutes, and task-2 for 2 hours and 7 minutes" I would be > recording > a date, and then I would convert "hours" and "minutes" to just minutes > (3 > hours and 37 minutes = 217 minutes) and save the date and the total > minutes. > All of the Date, DateTime, and Time objects in ruby are related to a > calendar, i.e., the want a date and a specific time, not a date and a > duration, which seems to me what you are after. Make sense? > > Cheers-- > > Charles-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Charles Johnson
2009-Mar-13 17:52 UTC
Re: Which is the best way to do this? (about save time data
On Fri, Mar 13, 2009 at 11:27 AM, John Smith < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Thanks for your help, Charles. I appreciate it. > > What I want is the duration needed to complete a specific task. So when > I have a lot of tasks, I will be able to search tasks width its > durations is bigger that 2 hours and 10 minutes, for example. I don''t > care about days, monts of yearsM I only need the duration. > So, should I use a Datetime in order to make search easy? > > Again, thanks a lot. >Because you want a duration rather than a specific time, I would convert hours and minutes to pure minutes and save that integer. That would make the searching easy and fast: @tasks = Task.find(:all, :order => :start_date, :conditions => ''duration >= 190'') or some such. Cheers-- Charles --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---