chronos icon indicating copy to clipboard operation
chronos copied to clipboard

Handle DateInterval Roll-Over

Open votemike opened this issue 6 years ago • 7 comments

It would be useful if there was a way to handle DateInterval Roll-Over. For example, I would hope that (ChronosInterval::seconds(107))->format('%I:%S') would output 01:47 rather than 00:107.

votemike avatar Apr 05 '18 09:04 votemike

Is there anything left to do on this?

othercorey avatar Oct 18 '19 22:10 othercorey

I have just tested version 1.2.8 and dev-master and the rollover still happens.

votemike avatar Oct 21 '19 07:10 votemike

Guys this is an issue, not a pull request. So nothing has actually changed :slightly_smiling_face:.

ADmad avatar Oct 21 '19 07:10 ADmad

PR #172 does mention it could fix this issue but I guess that's not the case.

ADmad avatar Oct 21 '19 07:10 ADmad

@ADmad I'm aware it's an issue. That's why I was asking why it was still open if #172 handles the roll-over.

@votemike You are saying it is still working correct?

othercorey avatar Oct 21 '19 07:10 othercorey

No. #172 does not fix the problem. My request remains open/valid/unfixed.

votemike avatar Oct 21 '19 07:10 votemike

Thanks for the clarification. I misunderstood the merged pull request then.

othercorey avatar Oct 21 '19 07:10 othercorey

While having this at seconds, minutes, hours and days level could make sense, when weeks and months are involved it is impossible to actually know the amount of weeks or months without knowing the actual start date.

It will lead to bad calculations if you enter 35 days. According to this it should create an interval with 1 months and..5 days? but then if you add this interval to 05/15 the result will be 06/20 but if the interval would have been created as 35 days the result would be 06/19. That's the reason DateInterval base class works that way.

So again, it makes sense for seconds minutes and hours and it is something we could improve but I feel it does not make sense the effort while this is something that can be easily done at app level.

To summarize I think this issue can be closed.

ajibarra avatar May 26 '23 10:05 ajibarra