In many instances, code needs to check if $time2 is some seconds after $time1.
While a duration object might be ideal to do that cleanly with very high resolution, in many common cases, it would be nice to be able to do this and have it DWIM:
if ( $time2 - $time1 > 300 ) { ... }
That works particularly nicely with time() (integer or fractional from Time::HiRes), avoiding having to generate/destroy a "now" object just for a simple comparison:
if ( $moment - time() > 300 ) { ... }
# versus this (which isn't even fractional epoch seconds)
if ( $moment - Time::Moment->now_utc->epoch > 300 ) { ... }
In many instances, code needs to check if
$time2
is some seconds after$time1
.While a duration object might be ideal to do that cleanly with very high resolution, in many common cases, it would be nice to be able to do this and have it DWIM:
That works particularly nicely with
time()
(integer or fractional from Time::HiRes), avoiding having to generate/destroy a "now" object just for a simple comparison: