microsoftgraph / microsoftgraph/msgraph-sdk-php

A bug when getting the dateTime for the start and end of an event

Aperta
#1,347 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

needs investigation
Lingua principale
PHP
Stelle
669
Fork
150
Merge medio
15h 21m
PR unite (30g)
3

Descrizione

I use this SDK to get user events from the Outlook calendar (https://outlook.office.com/calendar/view/week).

When a user uses a calendar on a website and wants to create an event for the whole day, he can do this in two ways:

  1. Manual - set the time from midnight to midnight.

  2. Use the "All day" checkbox
    In both cases I set the event for the whole day

The problem is that I get different responses from the API for an event that lasts a day.
When creating the event manually I get something like this:

{

    …
	
    "start": {
        "dateTime": "2023-09-17T21:00:00.0000000",
        "timeZone": "UTC"
    },
    "end": {
        "dateTime": "2023-09-18T21:00:00.0000000",
        "timeZone": "UTC"
    },
	
        "isAllDay":false,
	
    …

}

Dates and times were calculated relative to my time zone in Outlook settings.


But when creating an event, check the “All day” checkbox. The response will always be:

{

    …
	
    "start": {
        "dateTime": "2023-09-18T00:00:00.0000000",
        "timeZone": "UTC"
    },
    "end": {
         "dateTime": "2023-09-19T00:00:00.0000000",
         "timeZone": "UTC"
      },
	
    "isAllDay”:true,

     ...
}

The response always contains datetimes from midnight to midnight UTC.


Steps to reproduce:


  1. Use https://outlook.office.com/calendar/view/week

  2. In the settings, set the user's time zone with a UTC offset, for example - (UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius.

  3. Open a modal window for creating an event (click on an empty space on the calendar).
  4. Select the start and end datetime of the event, for example 2023-09-18 00:00 - for start and 2023-09-19 00:00 to end. Please note that this is a full day event.
  5. Execute a GET request to the calendar API using SDK (my code is shown below)
  6. The response contains the start and end date of the event, which is several hours less than midnight. This is expected behavior. The API calculates datetime relative to the Outlook user's time zone. Remember.

  7. Create a new event on the website, select dates, for example 2023-09-18 and 2023-09-19 but this time click on the “All day” checkbox.

  8. Execute a GET request and get the datetime from midnight to midnight.

  9. Compare the answer in the 1st case and the answer in the 2nd case.
Screenshot 2023-09-19 at 12 48 07

Current behavior:
For all-day events created manually and events created using the “All day” checkbox, I get a different responses

Expected behavior:
Get the same responses from the API when manually selecting a date from midnight to midnight and when selecting the "All day" checkbox.

My code:

$graph = new Graph();
$graph->setAccessToken($accessToken);
$timezone = new \DateTimeZone('UTC');
$start = new \DateTimeImmutable('now', $timezone);
$end = new \DateTimeImmutable('now +1 day +1 hour', $timezone);
$queryParams = [
    'startDateTime' => $start->format(\DateTimeInterface::ATOM),
    'endDateTime' => $end->format(\DateTimeInterface::ATOM),
];
$getEventsUrl = sprintf('/users/%s/calendar/calendarView/delta?%s', $msUserId, http_build_query($queryParams));
$calendarViewIterator = $graph->createCollectionRequest('GET', $getEventsUrl)->setReturnType(Event::class);

$events = [];
while (!$calendarViewIterator->isEnd()) {
    $events[] = $calendarViewIterator->getPage();
}


Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo i due casi di calendario di Outlook con la PHP calendarView/delta request mostrata e confronta i campi start, end e isAllDay restituiti. Determina quindi se la discrepanza è introdotta dalla SDK request o dalla Microsoft Graph calendar API; il completamento richiede di identificare il livello responsabile e documentare una correzione o una limitazione verificata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
api
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.