Creating a custom function that can be called from an instance variable.

Hello all,

I have a whole bunch of time stamps which I need to display in fractional hours or fractional days as the case may be.

Is there any chance I could do something like this: <<controller>> def HourDisp ... end @time = 12:30:00

Nik -

Create a helper method named say "time_as_fraction" and pass your time into it. Make that method do whatever munging you need it to do.

-philip

So: #t in hh:mm:ss format def HourDisp(t)   #t gets split in three parts hh,mm, and ss   new_t = t.split(':')   h=new_t[0] + new_t[1]/60 + new_t[2]/3600   return h end

<<view>> <%= HourDisp(12:30:00) %> #12.5

Thank You So Much Philip!

I tried it and I got it to work, Philip!

Thank You so much for your time. It's probably not my place to say that this stuff is probably elementary. This is why: Thank you so much for your time!!

Cheers!