gpt4 book ai didi

json - Office 365 API 为全天事件返回不正确的开始和结束日期时间

转载 作者:行者123 更新时间:2023-12-01 05:16:31 25 4
gpt4 key购买 nike

以下是重现该错误的步骤:

  • 检查您在 Office 365 中的时区设置,我的设置为美国东部,因此现在有 5 小时的偏移:http://take.ms/2qwxJ
  • 创建全天事件:http://take.ms/tRWSf
  • 通过在周 View 中查看事件并观察它不会与其他日期重叠,确认事件在您所在时区的上午 12 点至上午 12 点开始和结束。我还通过在与 Office 365 帐户同步的桌面 Outlook 客户端中查看,确认他们全天事件已按预期保存。在那里,您可以看到事件的时区是正确的 (EST)。
  • 通过 calendarview api 端点查看事件。请注意,它将时区显示为 UTC,并将开始和结束时间报告为 UTC 午夜到午夜。

  • 获取 https://outlook.office.com/api/v1.0/me/calendarview?startDateTime=2016-01-25T01:00:00Z&endDateTime=2016-02-01T23:00:00Z
    {  
    "@odata.context":"https://outlook.office.com/api/v1.0/$metadata#Me/CalendarView",
    "value":[
    {
    "@odata.id":"NOT IMPORTANT",
    "@odata.etag":"NOT IMPORTANT",
    "Id":"NOT IMPORTANT",
    "DateTimeCreated":"2016-01-20T20:48:49.3867149Z",
    "DateTimeLastModified":"2016-01-20T20:48:49.4179638Z",
    "ChangeKey":"NOT IMPORTANT",
    "Categories":[

    ],
    "StartTimeZone":"UTC",
    "EndTimeZone":"UTC",
    "ResponseStatus":{
    "Response":"Organizer",
    "Time":"0001-01-01T00:00:00Z"
    },
    "iCalUId":"NOT IMPORTANT",
    "Reminder":null,
    "HasAttachments":false,
    "Subject":"My all day event, in EST",
    "Body":{
    "ContentType":"HTML",
    "Content":"<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<style type=\"text/css\" style=\"\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n</head>\r\n<body dir=\"ltr\">\r\n<div id=\"divtagdefaultwrapper\" style=\"font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif\">\r\n<p><br>\r\n</p>\r\n</div>\r\n</body>\r\n</html>\r\n"
    },
    "BodyPreview":"",
    "Importance":"Normal",
    "Sensitivity":"Normal",
    "Start":"2016-01-26T00:00:00Z",
    "End":"2016-01-27T00:00:00Z",
    "Location":{
    "DisplayName":""
    },
    "IsAllDay":true,
    "IsCancelled":false,
    "IsOrganizer":true,
    "Recurrence":null,
    "ResponseRequested":true,
    "SeriesMasterId":null,
    "ShowAs":"Busy",
    "Type":"SingleInstance",
    "Attendees":[

    ],
    "Organizer":{
    "EmailAddress":{
    "Name":"brett",
    "Address":"NOT IMPORTANT"
    }
    },
    "WebLink":"NOT IMPORTANT"
    }
    ]
    }

    我希望开始和结束时间准确到东部标准时间的开始和结束时间
    "Start":"2016-01-26T05:00:00Z",
    "End":"2016-01-27T05:00:00Z",

    最佳答案

    您也可以轻松地从 v1 API 获取数据,
    您只需要确保在要求时间时您正在通过UTC时区和获取信息,您需要指定您期望的时区。

            $date = new DateTime("now", new DateTimeZone('UTC') );
    $deviceTimeStart = $date->format('Y-m-d\TH:i:s\Z');
    $deviceTimeEndPlus1 = $date->modify('+1 minutes');
    $deviceTimeEnd = $deviceTimeEndPlus1->format('Y-m-d\TH:i:s\Z');


    $httpHeader = array(
    "authorization: Bearer *****access_token*****",
    "cache-control: no-cache",
    "Prefer : outlook.timezone = \"Asia/Kolkata\""
    );

    $curl = curl_init();
    curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://graph.microsoft.com/v1.0/me/calendarview?startDateTime='.$TimeStart.'&endDateTime='.$TimeEnd.'&$select=Subject,Organizer,Start,End,bodyPreview,changeKey,location,attendees,organizer,lastModifiedDateTime',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_SSL_VERIFYPEER => 0,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => $httpHeader,
    )
    );
    $curlResponse = curl_exec($curl);
    $err = curl_error($curl);
    curl_close($curl);
    $responseNew = (array) json_decode($curlResponse, true);

    关于json - Office 365 API 为全天事件返回不正确的开始和结束日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34910743/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com