Seconds Until End of Day
A colleague of mine had to cache some html until the end of the day but found it difficult because cache expects expires_in
which is relative. We cant pass an absolute Time.now
:P
So we now have seconds_until_end_of_day
in 4.0.2
, but we use Rails 3
:(
But patching Time
is simple
def seconds_until_end_of_day
end_of_day.to_i - to_i
end
http://apidock.com/rails/v4.0.2/Time/seconds_until_end_of_day
Written by Dinesh Vasudevan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#