fix: read one-sided booking times as "ab" and "bis"

This commit is contained in:
fromme committed 2026-09-25 16:20:06 +02:00
1 parent 179769187b
commit bbb0a8aaa2
4 files changed
+29 -4

No files matched your search

+18 -1
View File
@@ -164,9 +164,26 @@ final readonly class TimeRange implements \Stringable
return self::format($this->endMinute);
}
/**
* One-sided spans read as "bis 13:00" / "ab 13:00" rather than 00:00–13:00 / 13:00–24:00:
* a half day booked by giving only one end has no meaningful other end, and midnight is not
* what the user typed.
*/
public function __toString(): string
{
return $this->isAllDay() ? 'ganztägig' : $this->start().'–'.$this->end();
if ($this->isAllDay()) {
return 'ganztägig';
}
if (self::DAY_START === $this->startMinute) {
return 'bis '.$this->end();
}
if (self::DAY_END === $this->endMinute) {
return 'ab '.$this->start();
}
return $this->start().'–'.$this->end();
}
private static function minutesOf(\DateTimeInterface $time): int