Google Calendar API iOS快速入门

时间:2018-05-16 02:32:35

标签: ios google-calendar-api xcode9

QuickstartApp正常运行,但它从当前日期开始提取所有未来事件。我想在当前日期之前获取活动。 这部分代码设置了当前日期:

query.timeMin = GTLRDateTime(date:Date())

我无法弄清楚获取不同日期的语法。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

当然,尝试这样的事情:

// Specify date components
var dateComponents = DateComponents()
dateComponents.year = 2019
dateComponents.month = 7
dateComponents.day = 11
dateComponents.timeZone = TimeZone(abbreviation: "EDT") // Eastern Daylight Time
dateComponents.hour = 8
dateComponents.minute = 34

// Create date from components
let userCalendar = Calendar.current // user calendar
let futureDate = userCalendar.date(from: dateComponents)

query.timeMin = GTLRDateTime(date: futureDate)

您可以使用其他方法创建不同的date found in this very related question