@@ -170,20 +170,34 @@ private function prepareNotificationSubject(INotification $notification): void {
170170 $ components [] = $ this ->l10n ->n ('%n minute ' , '%n minutes ' , $ diff ->i );
171171 }
172172
173- // Limiting to the first three components to prevent
174- // the string from getting too long
175- $ firstThreeComponents = array_slice ($ components , 0 , 2 );
176- $ diffLabel = implode (', ' , $ firstThreeComponents );
177-
178- if ($ diff ->invert ) {
179- $ title = $ this ->l10n ->t ('%s (in %s) ' , [$ title , $ diffLabel ]);
180- } else {
181- $ title = $ this ->l10n ->t ('%s (%s ago) ' , [$ title , $ diffLabel ]);
173+ if (!$ this ->hasPhpDatetimeDiffBug ()) {
174+ // Limiting to the first three components to prevent
175+ // the string from getting too long
176+ $ firstThreeComponents = array_slice ($ components , 0 , 2 );
177+ $ diffLabel = implode (', ' , $ firstThreeComponents );
178+
179+ if ($ diff ->invert ) {
180+ $ title = $ this ->l10n ->t ('%s (in %s) ' , [$ title , $ diffLabel ]);
181+ } else {
182+ $ title = $ this ->l10n ->t ('%s (%s ago) ' , [$ title , $ diffLabel ]);
183+ }
182184 }
183185
184186 $ notification ->setParsedSubject ($ title );
185187 }
186188
189+ /**
190+ * @see https://github.com/nextcloud/server/issues/41615
191+ * @see https://github.com/php/php-src/issues/9699
192+ */
193+ private function hasPhpDatetimeDiffBug (): bool {
194+ $ d1 = DateTime::createFromFormat (\DateTimeInterface::ATOM , '2023-11-22T11:52:00+01:00 ' );
195+ $ d2 = new DateTime ('2023-11-22T10:52:03 ' , new \DateTimeZone ('UTC ' ));
196+
197+ // The difference is 3 seconds, not -1year+11months+…
198+ return $ d1 ->diff ($ d2 )->y < 0 ;
199+ }
200+
187201 /**
188202 * Sets the notification message based on the parameters set in PushProvider
189203 *
0 commit comments