Distance_of_time_in_words and Time classes

There is <%= distance_of_time_in_words(Time.now, @a_time) %> before
xzy.

This does not work because when @a_time is stored, even though it is a
Time field and the class is Time, it includes a date. The Date isn’t
even that days date its the year 2000, hence the 2279 days ago.

So how do I set the date part of @a_time (a Time class) to today’s date
so that distance_of_time_in_words works as expected?

Cheers K.

AFM

Any ideas anyone? :slight_smile:

Kris L. wrote:

There is <%= distance_of_time_in_words(Time.now, @a_time) %> before
xzy.

This does not work because when @a_time is stored, even though it is a
Time field and the class is Time, it includes a date. The Date isn’t
even that days date its the year 2000, hence the 2279 days ago.

So how do I set the date part of @a_time (a Time class) to today’s date
so that distance_of_time_in_words works as expected?

Cheers K.

AFM

kris wrote:

Any ideas anyone? :slight_smile:

Is Time immutable ?

You may have to remove multiple days worth of seconds to get the sub-day
part.

difference_in_time_in_words( (Time.now - @a_time) mod (60 * 60 * 12) )

Alan