Hi Friends, I am new to ruby on rails. I want to convert seconds to minutes. like if 220sec= 3.40 minutes I did in this way sec/60 but it giving the false results ex : 70 sec = 110/6=1.8 but it is worong as for time Can u give any advice? -- 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 -~----------~----~----~----~------~----~------~--~---
On 3/15/07, Karni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi Friends, > > I am new to ruby on rails. > > I want to convert seconds to minutes. > > like if 220sec= 3.40 minutesNope:) 220 sec = 3 and 2/3 minutes, or 3.667 Which you can easily find out by 220 / 60.0 (Make sure you include the .0... forces it to float and keeps the stuff after the decimal point, which 220 / 60 would not) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think he meant 3 minutes 40 seconds by 3.40 minutes. I think. I wouldn''t have put it that way but the math works. RSL On 3/15/07, Luke Ivers <technodolt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On 3/15/07, Karni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > > Hi Friends, > > > > I am new to ruby on rails. > > > > I want to convert seconds to minutes. > > > > like if 220sec= 3.40 minutes > > > Nope:) 220 sec = 3 and 2/3 minutes, or 3.667 > Which you can easily find out by 220 / 60.0 > (Make sure you include the .0... forces it to float and keeps the stuff > after the decimal point, which 220 / 60 would not) > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mar 15, 2007, at 9:35 AM, Luke Ivers wrote:> On 3/15/07, Karni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > Hi Friends, > > I am new to ruby on rails. > > I want to convert seconds to minutes. > > like if 220sec= 3.40 minutes > > Nope:) 220 sec = 3 and 2/3 minutes, or 3.667 > Which you can easily find out by 220 / 60.0 > (Make sure you include the .0... forces it to float and keeps the > stuff after the decimal point, which 220 / 60 would not)Perhaps you mean 220sec => 3:40 class Integer def to_minutes "%d:%02d" % [ self/60, self%60 ] end end 220.to_minutes => "3:40" -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
Ahhh... On 3/15/07, Russell Norris <sconds-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I think he meant 3 minutes 40 seconds by 3.40 minutes. I think. I wouldn''t > have put it that way but the math works. > > RSL > > On 3/15/07, Luke Ivers <technodolt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > On 3/15/07, Karni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote: > > > > > > > > > Hi Friends, > > > > > > I am new to ruby on rails. > > > > > > I want to convert seconds to minutes. > > > > > > like if 220sec= 3.40 minutes > > > > > > Nope:) 220 sec = 3 and 2/3 minutes, or 3.667 > > Which you can easily find out by 220 / 60.0 > > (Make sure you include the .0... forces it to float and keeps the stuff > > after the decimal point, which 220 / 60 would not) > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Or: Time.at(220).strftime("%M:%S") Piet. ________________________________ From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Luke Ivers Sent: donderdag 15 maart 2007 15:04 To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: SEC to minutes Ahhh... --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Great minds think alike! RSL On 3/15/07, Rob Biedenharn <Rob-GBZH0y1GwQfnZcttdmLDtcI/UQi/AW5J@public.gmane.org> wrote:> > On Mar 15, 2007, at 9:35 AM, Luke Ivers wrote: > > On 3/15/07, Karni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > Hi Friends, > > > > I am new to ruby on rails. > > > > I want to convert seconds to minutes. > > > > like if 220sec= 3.40 minutes > > > Nope:) 220 sec = 3 and 2/3 minutes, or 3.667 > Which you can easily find out by 220 / 60.0 > (Make sure you include the .0... forces it to float and keeps the stuff > after the decimal point, which 220 / 60 would not) > > > Perhaps you mean 220sec => 3:40 > > class Integer > def to_minutes > "%d:%02d" % [ self/60, self%60 ] > end > end > > 220.to_minutes > => "3:40" > > -Rob > Rob Biedenharn http://agileconsultingllc.com > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@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-/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 -~----------~----~----~----~------~----~------~--~---
Russell Norris wrote:> Great minds think alike! > > RSLVery thankful to all ,i got solution.. Thanks alot -- 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 -~----------~----~----~----~------~----~------~--~---