The changes in b79adc4 had a bug where if the time in the String was in standard time but the current time was in daylight savings then the calculated adjustment was off by an hour. This commit fixes this and adds extra tests for the following: * time in string is standard time, current time is standard time * time in string is standard time, current time is daylight savings * time in string is daylight savings, current time is standard time * time in string is daylight savings, current time is daylight savings Fixes #10306.
Use the standard library's `DateTime.parse` because it's marginally faster and supports partial date/time strings. Benchmark: user system total real old 3.980000 0.000000 3.980000 ( 3.987606) new 3.640000 0.010000 3.650000 ( 3.641342)
This commit standardises the return value of `to_time` to an instance of `Time` in the local system timezone, matching the Ruby core and standard library behavior. The default form for `String#to_time` has been changed from :utc to :local but research seems to suggest the latter is the more common form. Also fix an edge condition with `String#to_time` where the string has a timezone offset in it and the mode is :local. e.g: # Before: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 05:00:00 -0500 # After: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 00:00:00 -0500 Closes #2453
The Time.time_with_datetime_fallback, Time.utc_time and Time.local_time methods were added to handle the limitations of Ruby's native Time implementation. Those limitations no longer apply so we are deprecating them in 4.0 and they will be removed in 4.1.