chronic icon indicating copy to clipboard operation
chronic copied to clipboard

Can't parse negative offsets with Active Support 4.2.7.1

Open ren90 opened this issue 8 years ago • 1 comments

Hey guys,

I'm trying to upgrade my Active Support to 4.2.7.1 but then Chronic can no longer parse negative offsets (when rewinding from 00, in other words, when I parse a negative amount of minutes, and the current time has 0 minutes, it breaks). This is due to the fact that Active Support deprecated the Time.utc_time method (called in the Time.local method, used by Chronic) in favour of Time.utc that does not accept negative offsets. This also happens without Active Support, when basing on the Ruby Time class.

Example:

#Timecop for freezing time where the bug occurs
require 'timecop'
require 'chronic'

#lets set a timestamp that has zero minutes
Timecop.freeze('2016-01-01 14:00:49')
#lets ask for the last minute
Chronic.parse('last minute')
#BAM

#lets set a timestamp that hasn't zero minutes
Timecop.freeze('2016-01-01 00:33:49')
#lets ask for the last minute
Chronic.parse('last minute')
#NICES

#lets set a timestamp that has zero hours
Timecop.freeze('2016-01-01 00:14:49')
#lets ask for the last minute
Chronic.parse('last hour')
#BAM

#lets set a timestamp that hasn't zero hours
Timecop.freeze('2016-01-01 14:00:49')
#lets ask for the last minute
Chronic.parse('last hour ')
#NICES

Thanks in advance, Best regards

ren90 avatar Nov 14 '16 14:11 ren90

Seems to work in my rewrite branch

davispuh avatar Aug 17 '17 20:08 davispuh