New time object with custom value

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.

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

On Thu, Jul 10, 2008 at 11:04 AM, Bill W. [email protected]
wrote:

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/

Hi Bill W.,
Thanks for your reply. But i am still struggling to use the
ActiveSupport::CoreExtensions::DateTime::Calculations#change. Can you
give me an example?

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.

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

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

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.