File tree Expand file tree Collapse file tree 2 files changed +39
-5
lines changed
Expand file tree Collapse file tree 2 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -167,10 +167,15 @@ private function output(callable $type): EntryCollection|LengthAwarePaginator
167167 $ occurrences = $ this ->entries ()->occurrences (generator: $ type );
168168
169169 if (! is_null ($ this ->timezone )) {
170- $ occurrences ->transform (fn (Entry $ occurrence ) => $ occurrence
171- ->setSupplement ('start ' , $ occurrence ->start ->setTimezone ($ this ->timezone ))
172- ->setSupplement ('end ' , $ occurrence ->end ->setTimezone ($ this ->timezone ))
173- );
170+ $ occurrences ->transform (function (Entry $ occurrence ) {
171+ $ start = $ occurrence ->start ->setTimezone ($ this ->timezone );
172+ $ end = $ occurrence ->end ->setTimezone ($ this ->timezone );
173+
174+ return $ occurrence
175+ ->setSupplement ('start ' , $ start )
176+ ->setSupplement ('end ' , $ end )
177+ ->setSupplement ('spansDay ' , !$ start ->isSameDay ($ end ));
178+ });
174179 }
175180
176181 if ($ this ->offset ) {
Original file line number Diff line number Diff line change 410410 ]);
411411});
412412
413- test ('uses the timezone param when generating occurrences ' , function () {
413+ it ('uses the timezone param when generating occurrences ' , function () {
414414 Carbon::setTestNow (now ()->setTimeFromTimeString ('10:00 ' ));
415415
416416 $ this ->tag
427427 expect ($ occurrences )->toHaveCount (1 )
428428 ->first ()->start ->timezone ->getName ()->toBe ('America/Vancouver ' );
429429});
430+
431+ it ('sets "spansDay" ' , function () {
432+ Carbon::setTestNow (now ()->setTimeFromTimeString ('10:00 ' ));
433+
434+ Entry::make ()
435+ ->collection ('events ' )
436+ ->slug ('recurring-event ' )
437+ ->id ('recurring-event ' )
438+ ->data ([
439+ 'title ' => 'Event ' ,
440+ 'start_date ' => Carbon::now ()->toDateString (),
441+ 'start_time ' => '11:00 ' ,
442+ 'end_time ' => '23:00 ' ,
443+ ])->save ();
444+
445+ $ this ->tag
446+ ->setContext ([])
447+ ->setParameters ([
448+ 'collection ' => 'events ' ,
449+ 'from ' => Carbon::now ()->subDay (),
450+ 'timezone ' => 'Europe/Kyiv ' ,
451+ 'to ' => Carbon::now ()->addDays (2 ),
452+ ]);
453+
454+ $ occurrences = $ this ->tag ->between ();
455+
456+ expect ($ occurrences )->toHaveCount (1 )
457+ ->first ()->spansDay ->toBeTrue ();
458+ });
You can’t perform that action at this time.
0 commit comments