Skip to content

Calendar appointment wrong end time if event start is inside summertime and end time is in wintertime #227

@a-schild

Description

@a-schild

When the start date+time of a calendar entry is in summer time and the date+time is in wintertime, then the end time is off by 1 hour (for switzerland)

How to reproduce:

  1. Create a calendar entry in churchtool, which starts
    2025-10-25 at 23:00
    and ends at
    2025-10-26 at 11:00
  2. Fetch the calendar entry from Churchtools via the /calendar/[id]/appointments?from=2025-10-25&to=2025-10-26 endpoint
curl -X 'GET' \
  'https://your.church.tools/api/calendars/2/appointments?from=2025-10-25&to=2025-10-26' \
  -H 'accept: application/json' \
  -H 'Authorization: XXXXXXXXXXXXX'

Result returned via API

{
  "data": [
    {
      "appointment": {
        "base": {
          "title": "Test Sommer-Winterzeit",
          "isInternal": false,
          "startDate": "2025-10-25T21:00:00Z",
          "endDate": "2025-10-26T10:00:00Z",
          "allDay": false,
        "calculated": {
          "startDate": "2025-10-25T21:00:00Z",
          "endDate": "2025-10-26T11:00:00Z"
        }
      },

As you see, the start + end dates+times are in UTC

  1. Now do fetch the same calendar entries from CT via the churchtools-api library, v 2.1.0
    Here how we debug:
    logDebug("Caption: ".$ctCalEntry->getCaption()." StartDate: ".$ctCalEntry->getStartDate()." EndDate: ".$ctCalEntry->getEndDate(). " Is allday: ".$ctCalEntry->getAllDay().($isRepeating ? " Is repeating" : " Is not repeating")); logDebug("Start date time" .serialize($ctCalEntry->getStartDateAsDateTime())); logDebug("End date time" .serialize($ctCalEntry->getEndDateAsDateTime())); $eDate = new \DateTime($ctCalEntry->getEndDate()); logDebug("EndDate without TZ conversion: ".$eDate->format('Y-m-d H:i:s T'));

Log output:

DBG: Caption: Test Sommer-Winterzeit StartDate: 2025-10-25T21:00:00Z EndDate: 2025-10-26T11:00:00Z Is allday: false Is not repeating
DBG: Start date timeO:17:"DateTimeImmutable":3:{s:4:"date";s:26:"2025-10-25 21:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}
DBG: End date timeO:17:"DateTimeImmutable":3:{s:4:"date";s:26:"2025-10-26 11:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}
DBG: EndDate without TZ conversion: 2025-10-26 11:00:00 Z

As can be seen:

  • the start time is still in UTC (21:00) which is correct
  • the end time is already converted into CET (11:00) instead of remaining in UTC
  • Unfortunally, the TZ associated is still UTC, so when processing the result, we add another hour, and the end time is therefor off by one hour
  • We have not tested what happes for event spanning winter->summertime switch, but we probably have the same issue here, just in the other direction.

Original bug report:
a-schild/churchtools-wp-calendarsync#14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions