arnau / ISO8601

Ruby parser to work with ISO8601 dateTimes and durations — http://en.wikipedia.org/wiki/ISO_8601
MIT License
75 stars 15 forks source link

Resolving issue with ISO8601::Months#factor calculation when the duration is negative. #10

Closed mschile closed 10 years ago

mschile commented 10 years ago

When passing in a negative duration, all atoms correctly calculate their factor except for the Months class. For instance, if -P3M is the duration with a base date of 2012-1-1, the months is incorrectly calculated as -2 which causes an argument out of range exception from Time#utc.

Also, for positive durations, if the base month plus atom is evenly divisible by 12 but greater than 12, this resulted in a month calculation of 0 which also caused an argument out of range exception. For instance, if P19M is the duration with a base date of 2012-5-1, the months is incorrectly calculated as 0.

arnau commented 10 years ago

Thanks @mschile