cakephp / chronos

A standalone DateTime library originally based off of Carbon
http://book.cakephp.org/chronos
MIT License
1.34k stars 61 forks source link

Cannot construct a relative date that always points to the _next_ future date & time #406

Open Bilge opened 11 months ago

Bilge commented 11 months ago

If we construct a date at midday, Tuesday with new Chronos('Tue 12:0'), but we are currently at 4pm tuesday, then this date will be 4 hours in the past. Let's suppose we always want the constructed date to be in the future. We could "fix" this by specifying new Chronos('next Tue 12:0'), which will point to 7 days ahead. However, if we are currently at 9am on a Tuesday, this will still point 7 days ahead, instead of to midday on the current day, because the next specifier only considers the date portion of the date/time compound and completely ignores the time. Therefore it is impossible to construct a relative date & time that always points to the next future occurrence of that specific date and time.

othercorey commented 10 months ago

Chronos uses DateTimeImmutable for all parsing so we'd have to perform a post-parse adjustment to get this behavior.