redox/redmine — comment on commit 08686ae6d3013c982003528ad762017aed75e34b
File:  line 0
By redox:

On 7 oct. 2011, at 11:45, Etienne Massip wrote:

> Ok, I don't get the "ruby 1.9 inside" part, could you please explain this ?
>
> Because Toshi/you committed to Redmine trunk which is not Ruby 1.9 compatible, and because I don't see any Ruby 1.9 specific code in this change.
>

Finally, nothing to deal with ruby 1.9. The fix ensures we're use UTC.

===========

require 'rubygems'
require 'active_support/core_ext/date/conversions'
require 'active_support/core_ext/date/calculations'
require 'active_support/core_ext/time/calculations'

from = Date.yesterday # 2011-10-07
to = Date.today # 2011-10-08

# before
puts (from - 1).to_time.end_of_day.to_s # 2011-10-06 23:59:59 +0200 (KO, not UTC)

# first try
puts (from - 1).to_time.utc.end_of_day.to_s # 2011-10-05 23:59:59 UTC (KO, not the 5)

# 08686ae6
from_yesterday = from - 1
from_yesterday_utc = Time.gm(from_yesterday.year, from_yesterday.month, from_yesterday.day)
puts from_yesterday_utc.end_of_day.to_s # 2011-10-06 23:59:59 UTC (OK, the 6 + UTC)

===========