I ran across a pretty non-intuitive (IMHO) behavior with Date::Delta
irb(main):001:0> require ‘date/delta’
irb(main):002:0> d = Date.today - Date.today + Date::Delta.months(1)
Okay, I figured out where this came from:
Date::Delta is implemented via the linear map
1 day -> 1
1 month -> i
from the timedeltas to the complex numbers.
It’s because the length of one month is different depending on where it
The multiplication of complex numbers is irrelevant here.
So isn’t it strange that this implementation detail comes up when doing
arithmetic with times? Would it be better if #<Date::Delta: +(0d
00:00’00"000)+(0y 1m) (0/1+1/1i)>
What does everyone else think?