hi, I need to construct anew time object with hour->7,min-55,sec-33. Then how could i do it?. As i search for it, I found no constructor to make time object like this. Anybody? Thanks, -Sadeesh kumar. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Sadeesh, sadeesh kumar wrote:> I need to construct anew time object > with hour->7,min-55,sec-33. Then how > could i do it?.Take a look at the ActiveSupport::CoreExtensions::DateTime::Calculations#change method. There''s no Time.new(args) method, but I think that''ll get you what you''re looking for. HTH, Bill --~--~---------~--~----~------------~-------~--~----~ 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 Thu, Jul 10, 2008 at 11:04 AM, Bill Walton <bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> > Hi Sadeesh, > > sadeesh kumar wrote: > > > I need to construct anew time object > > with hour->7,min-55,sec-33. Then how > > could i do it?. > > Take a look at the > ActiveSupport::CoreExtensions::DateTime::Calculations#change method. > There''s no Time.new(args) method, but I think that''ll get you what you''re > looking for. >Also, I''m not sure what Sadeesh meant by a time object with hour->7, min-55, sec-33. The ruby Time class is really a point in time, so it represents, say 4:06 pm on July 10, 2008, rather than 16 hours and 6 minutes. Rails provides an ActiveSupport::Duration class which does represent time intervals, they are created using methods on integers so you can do: 7.hours + 66.minutes + 33.seconds And you can add or subtract a duration to/from a time so; Time.now + 7.hours + 66.minuts + 33.seconds -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
Hi Bill Walton, Thanks for your reply. But i am still struggling to use the ActiveSupport::CoreExtensions::DateTime::Calculations#change. Can you give me an example? On Jul 11, 1:13 am, "Rick DeNatale" <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Jul 10, 2008 at 11:04 AM, Bill Walton <bill.wal...-xwVYE8SWAR3R7s880joybQ@public.gmane.org> > wrote: > > > > > Hi Sadeesh, > > > sadeesh kumar wrote: > > > > I need to construct anew time object > > > with hour->7,min-55,sec-33. Then how > > > could i do it?. > > > Take a look at the > > ActiveSupport::CoreExtensions::DateTime::Calculations#change method. > > There''s no Time.new(args) method, but I think that''ll get you what you''re > > looking for. > > Also, I''m not sure what Sadeesh meant by a time object with hour->7, min-55, > sec-33. > > The ruby Time class is really a point in time, so it represents, say 4:06 > pm on July 10, 2008, rather than 16 hours and 6 minutes. > > Rails provides an ActiveSupport::Duration class which does represent time > intervals, they are created using methods on integers so you can do: > > 7.hours + 66.minutes + 33.seconds > > And you can add or subtract a duration to/from a time so; > > Time.now + 7.hours + 66.minuts + 33.seconds > > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
Hi Sadeesh, sadeesh kumar wrote:> Thanks for your reply. But i am still struggling to use the > ActiveSupport::CoreExtensions::DateTime::Calculations#change. Can you > give me an example?What have you tried? What were the results and how did they confuse you? Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bill, require ''activesupport'' print ActiveSupport::CoreExtensions::Time::Calculations::change(13) print ActiveSupport::CoreExtensions::Time::Calculations.change(13) Well my problem is, I don''t know how to use change method. Thanks, -Sadeesh kumar. On Jul 11, 8:00 am, "Bill Walton" <bill.wal...-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> Hi Sadeesh, > > sadeesh kumar wrote: > > Thanks for your reply. But i am still struggling to use the > > ActiveSupport::CoreExtensions::DateTime::Calculations#change. Can you > > give me an example? > > What have you tried? What were the results and how did they confuse you? > > Best regards, > Bill--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Sadeesh, sadeesh kumar wrote:> Bill, > require ''activesupport'' > print ActiveSupport::CoreExtensions::Time::Calculations::change(13) > print ActiveSupport::CoreExtensions::Time::Calculations.change(13) > > Well my problem is, I don''t know how to use change method.Wow. Sorry about that. Check the documentation for the change method (bottom left frame) in ActiveSupport::CoreExtensions::Time::Calculations at api.rubyonrails.org. If it''s not obvious how to use it at that point, try it out in irb. When you have some concrete ''tried this, got that, don''t understand why'' type results, come back. Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Rick DeNatale, Thanks for your reply. Any example code would be appreciated. Thanks, -Sadeesh.> > Also, I''m not sure what Sadeesh meant by a time object with hour->7, min-55, > > sec-33. >> > The ruby Time class is really a point in time, so it represents, say 4:06 > > pm on July 10, 2008, rather than 16 hours and 6 minutes. > > > Rails provides an ActiveSupport::Duration class which does represent time > > intervals, they are created using methods on integers so you can do: > > > 7.hours + 66.minutes + 33.seconds > > > And you can add or subtract a duration to/from a time so; > > > Time.now + 7.hours + 66.minuts + 33.seconds > > > -- > > Rick DeNatale > > > My blog on Rubyhttp://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---