cakephp / chronos

A standalone DateTime library originally based off of Carbon

Home Page:http://book.cakephp.org/chronos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Bilge opened this issue · comments

commented

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.

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