Skip to content

Commit 709c4a2

Browse files
gnutixclaude
andcommitted
Reject a trailing lowercase t in Duration::parse()
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y1vvcS4Cb7XByR7zhpyQNF
1 parent 81915a3 commit 709c4a2

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/Duration.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static function parse(string $text): Duration
8888
[, $sign, $days, $t, $hours, $minutes, $seconds, $nanos] = $matches;
8989

9090
if ($hours === '' && $minutes === '' && $seconds === '') {
91-
if ($days === '' || $t === 'T') {
91+
if ($days === '' || $t !== '') {
9292
throw Parser\DateTimeParseException::invalidDuration($text);
9393
}
9494
}

‎tests/DurationTest.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public static function providerParse(): array
165165
['pT-0S', 0, 0],
166166
['Pt0S', 0, 0],
167167
['PT-0s', 0, 0],
168+
['p1dt2h', 93600, 0],
168169

169170
['PT0.1S', 0, 100000000],
170171
['PT-0.1S', -1, 900000000],
@@ -270,6 +271,9 @@ public static function providerParseFailureThrowsException(): array
270271
['-PT'],
271272
['+PT'],
272273
['P1DT'],
274+
['P1Dt'],
275+
['p1dt'],
276+
['-P1Dt'],
273277
['P1DTS'],
274278
['PTS'],
275279
['PT0'],

0 commit comments

Comments
 (0)