floraison / fugit

time tools (cron, parsing, durations, ...) for Ruby, rufus-scheduler, and flor
MIT License
353 stars 29 forks source link

easier way to subtract a duration from a time #85

Closed mreinsch closed 1 year ago

mreinsch commented 1 year ago

previous behaviour resulted in same as addition:

Fugit.parse('1Y') + Time.parse("2023-01-19T12:07:00T")
# => 2024-01-19T12:07:00T

Fugit.parse('1Y') - Time.parse("2023-01-19T12:07:00T")
# => 2024-01-19T12:07:00T

With this change, the duration is now subtracted from the time:

Fugit.parse('1Y') + Time.parse("2023-01-19T12:07:00T")
# => 2024-01-19T12:07:00T

Fugit.parse('1Y') - Time.parse("2023-01-19T12:07:00T")
# => 2022-01-19T12:07:00T

Mathematically this isn't quite correct I suppose, but neither is the current behaviour.

jmettraux commented 1 year ago

ありがとうございます!

jmettraux commented 1 year ago

@mreinsch thanks again. hisashiburija! Are you OK if I release fugit 1.8.1 with your fixes tomorrow morning GMT+9?

mreinsch commented 1 year ago

@jmettraux it's been quite a while indeed! And first time I manage to contribute back to one of your projects :-) Thanks very much for the quick merge. No need to hurry on the release, I'll use master for now.