Dual-Life / Time-Piece

Object Oriented time objects
Other
15 stars 33 forks source link

Suggestion to add a new method: add_days #65

Open gugod opened 11 months ago

gugod commented 11 months ago

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.

Are we up for adding these two methods ?