# New Ticket Created by Alex Jakimenko # Please include the string: [perl #127161] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=127161 >
These are not working: Code: say DateTime.new(‘2016-01-31T05:00:00Z’).earlier(months => -1) Result: Month out of range. Is: 0, should be in 1..12 in block <unit> at /tmp/CfLpbWf_RV line 1 Code: say DateTime.new(‘2016-01-31T05:00:00Z’).later(months => -1) Result: Month out of range. Is: 0, should be in 1..12 in block <unit> at /tmp/jdJBjXGCdA line 1 But all these do: Code: say DateTime.new(‘2016-01-31T05:00:00Z’).earlier(years => -1) Result: 2015-01-31T05:00:00Z Code: DateTime.new(‘2016-01-31T05:00:00Z’).earlier(days => -1) Result: 2016-02-01T05:00:00Z Code: DateTime.new(‘2016-01-31T05:00:00Z’).earlier(seconds => -1) Result: 2016-01-31T05:00:01Z Code: say DateTime.new(‘2016-01-31T05:00:00Z’).later(seconds => -1) Result: 2016-01-31T04:59:59Z Personally I think that negative values should be allowed (so TIMTOWTDI-ish!).