保存和加载后,为什么“Appointment.Recurrence.Until”(意外)关闭?

时间:2016-09-14 19:17:58

标签: calendar uwp windows-10-universal windows-10-mobile

我正在使用AppointmentCalendar将约会保存到AppointmentCalendar.SaveAppointmentAsync(...)。此约会是包含Recurrence信息的系列

保存约会后,我使用约会的GetAppointmentAsync在同一日历上调用LocalId,再次检索同一个约会。

以下是意外行为:加载的约会存在差异:Recurrence.Until日期关闭一个。 这是为什么?

以下是序列化为JSON的约会约会:

Appointment我保存:

{ 
    "Location": "", 
    "AllDay": false, 
    "Organizer": null, 
    "Duration": "00:45:00", 
    "Details": "", 
    "BusyStatus": 0, 
    "Recurrence": { 
        "Unit": 1, 
        "Occurrences": 260, 
        "Month": 1, 
        "Interval": 1, 
        "DaysOfWeek": 62, 
        "Day": 1, 
        "WeekOfMonth": 0, 
        "Until": "2016-12-31T01:00:00+01:00",
        "TimeZone": "Europe/Budapest", 
        "RecurrenceType": 0, 
        "CalendarIdentifier": "" 
    }, 
    "Subject": "test", 
    "Uri": null, 
    "StartTime": "2016-01-04T11:30:00+01:00", 
    "Sensitivity": 0, 
    "Reminder": null, 
    "Invitees": {}, 
    "AllowNewTimeProposal": true, 
    "UserResponse": 0, 
    "RoamingId": "c,b,fd", 
    "ReplyTime": null, 
    "IsResponseRequested": true, 
    "IsOrganizedByUser": false, 
    "IsCanceledMeeting": false, 
    "OnlineMeetingLink": "", 
    "HasInvitees": false, 
    "CalendarId": "b,37,355", 
    "LocalId": "c,37,20a3", 
    "OriginalStartTime": null, 
    "RemoteChangeNumber": 0, 
    "DetailsKind": 0, 
    "ChangeNumber": 39537577 
}

在通过调用Appointment检索它之后,这是同一个GetAppointmentAsync

{ 
    "Location": "", 
    "AllDay": false, 
    "Organizer": null, 
    "Duration": "00:45:00", 
    "Details": "", 
    "BusyStatus": 0, 
    "Recurrence": { 
        "Unit": 1, 
        "Occurrences": 260, 
        "Month": 1, 
        "Interval": 1, 
        "DaysOfWeek": 62, 
        "Day": 1, 
        "WeekOfMonth": 0, 
        "Until": "2016-12-30T01:00:00+01:00",
        "TimeZone": "Europe/Budapest", 
        "RecurrenceType": 0, 
        "CalendarIdentifier": "GregorianCalendar" 
    }, 
    "Subject": "test", 
    "Uri": null, 
    "StartTime": "2016-01-04T11:30:00+01:00", 
    "Sensitivity": 0, 
    "Reminder": null, 
    "Invitees": {}, 
    "AllowNewTimeProposal": true, 
    "UserResponse": 0, 
    "RoamingId": "c,b,fd", 
    "ReplyTime": null, 
    "IsResponseRequested": true, 
    "IsOrganizedByUser": false, 
    "IsCanceledMeeting": false, 
    "OnlineMeetingLink": "", 
    "HasInvitees": false, 
    "CalendarId": "b,37,355", 
    "LocalId": "c,37,20a3", 
    "OriginalStartTime": null, 
    "RemoteChangeNumber": 0, 
    "DetailsKind": 0, 
    "ChangeNumber": 39537577 
}

区分这些JSON,您会在Recurrence部分得到两个不同之处:

CalendarIdentifier在保存的原始约会中为空(因为setter是私有的)。但更重要的是:Recurrence.Until不同!

Recurrence.Until预约保存:“2016-12-31T01:00:00 + 01:00”

Recurrence.Until加载后预约:“2016-12-30T01:00:00 + 01:00”

有一天不见了。

这是为什么?保存约会时我还需要做什么吗?或者更糟糕的是:它只是我的日历和约会的边缘情况,甚至可能连接到当前日期?

(SDK Version 10.0.14393.0,Win 10 Anniversary)

1 个答案:

答案 0 :(得分:1)

我做了很多测试。在我的测试中,如果我在上午8:00之前设置直到前一天的时间,recurrence.until的结果将在您上面显示的一天中关闭,设置其他时间将在正确的一天但无论何时你实际设定的结果将是上午8点。详情请参阅以下测试结果。

enter image description here

似乎相对于时区(我的时区是UTC + 8:00)。简单的解决方法是在设置until时,只需将日期设置为如下所示:recurrence.Until = UntilDatePicker.Date;,不要将具体时间设置为until。实际上,即使我们在日历应用中手动设置until,我们也不需要特定的时间。

enter image description here

我还上传了一个可以下载的演示版以供进一步测试。