cakephp / cakephp/chronos

ChronosDate::modify() fails on 'second' relative keywords

Open Beginner friendly
#532 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
1.4k
Forks
71
Avg merge
1d 59m
Merged PRs (30d)
2

Description

Description

Calling modify() on a ChronosDate instance with relative expressions such as 'second monday of this month' throws an error.

Steps to Reproduce
use Cake\Chronos\ChronosDate;

$date = (new ChronosDate('2026-09-01'))->modify('second monday of this month');
Expected Behavior

The ChronosDate instance is modified to the second Monday of the month.

Actual Behavior

Throws an exception:

Cannot modify date objects by time values

Environment
  • cakephp/chronos: 3.5.1
  • PHP: 8.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ChronosDate::modify() with the reproducing expression 'second monday of this month'. Check why this relative keyword is treated as a time value, then add a regression test covering the provided date and expression. Done means the call returns the second Monday without raising the time-value exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.