I often need to do some simple datetime calculation in test code to create a timestamp in the past, and that's when it became a bit inconsistent, because to refer to a timestamp about a month ago, we could do:
Time::Piece->new()->add_months(-1)
But for 1 day ago, we must do:
Time:::Piece->new() - ONE_DAY
It would seem intuitive to me that there ought to be an add_days method, but no.
Sometimes I need to append an ->strftime() after making a past timestamps. Being able to "time travel" with a method call do help making it look better and easier to write.
I often need to do some simple datetime calculation in test code to create a timestamp in the past, and that's when it became a bit inconsistent, because to refer to a timestamp about a month ago, we could do:
But for 1 day ago, we must do:
It would seem intuitive to me that there ought to be an
add_days
method, but no.Sometimes I need to append an
->strftime()
after making a past timestamps. Being able to "time travel" with a method call do help making it look better and easier to write.Are we up for adding these two methods ?