From 467a6bf8900bd0c37f30e74b4adeb6ef801d4eb5 Mon Sep 17 00:00:00 2001 From: Piotr Filip <6465816-piotrfilip@users.noreply.gitlab.com> Date: Tue, 29 Jun 2021 12:17:33 +0000 Subject: [PATCH] fix: Rfc5545Duration __toString returns "P" when in_duration==0 --- inc/RRule.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inc/RRule.php b/inc/RRule.php index 2bde986e..cd8aeb1f 100644 --- a/inc/RRule.php +++ b/inc/RRule.php @@ -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) ) {