brick / date-time

Date and time library for PHP
MIT License
337 stars 30 forks source link

Stopwatch Lap Duration #98

Closed rodnaph closed 7 months ago

rodnaph commented 8 months ago

Return the lap duration when stopping the Stopwatch, which will be the duration since the last start.

If the stopwatch is not started, then the duration will be zero.

Use case - using a stopwatch to perform multiple duration timings, and then fetch the total elapsed time at the end (I can't see this is possible now, please direct me if I've just overlooked it though).

Note: CI failure does not seem related to my changes, as above though let me know if I missed something.

gnutix commented 8 months ago

Sorry for the CI failure, it's fixed by #100.

BenMorel commented 8 months ago

Hi, I like this idea, this feature is indeed missing!

What about adding a getLapTime() as well, to be able to get the duration since the last start without stopping?

By the way you can rebase now, this will fix the CS issue.

rodnaph commented 8 months ago

What about adding a getLapTime() as well, to be able to get the duration since the last start without stopping?

Thanks, I've added that method, let me know if there's anything I've missed.

BenMorel commented 8 months ago

Apart from this, returning the duration in stop() looks good to me, @rodnaph. Let's fix the nitpicks and merge it!

BenMorel commented 7 months ago

Thank you, @rodnaph!

BenMorel commented 7 months ago

Released as 0.6.3.