Skip to content

Commit 59d6245

Browse files
committed
allow for zero-second durations.
1 parent e394101 commit 59d6245

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/ValueObjects/DurationValue.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public function format(): string
5858
$value .= "{$this->interval->s}S";
5959
}
6060

61+
if ($value == "P" || $value == "-P") {
62+
return "PT0S";
63+
}
64+
6165
return $value;
6266
}
6367
}

tests/ValueObjects/DurationValueTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
assertEquals('P4DT3H2M1S', $value->format());
2323
});
2424

25+
test('it can create 0 seconds duration', function () {
26+
$value = DurationValue::create('PT0S');
27+
28+
assertEquals('PT0S', $value->format());
29+
});
30+
2531
test('it can use a regular string as duration', function () {
2632
$value = DurationValue::create('PT5M');
2733

0 commit comments

Comments
 (0)