fix: Rfc5545Duration __toString returns "P" when in_duration==0

This commit is contained in:
Piotr Filip 2021-06-29 12:17:33 +00:00 committed by Andrew Ruthven
parent 04f2da406e
commit 467a6bf890

View File

@ -152,7 +152,9 @@ class Rfc5545Duration {
if ( empty($this->as_text) ) {
$this->as_text = ($this->epoch_seconds < 0 ? '-P' : 'P');
$in_duration = abs($this->epoch_seconds);
if ( $in_duration >= 86400 ) {
if ( $in_duration == 0 ) {
$this->as_text .= '0D';
} elseif ( $in_duration >= 86400 ) {
$this->days = floor($in_duration / 86400);
$in_duration -= $this->days * 86400;
if ( $in_duration == 0 && ($this->days / 7) == floor($this->days / 7) ) {