【发布时间】:2020-02-28 16:15:59
【问题描述】:
假设我有一个程序可以提醒用户他们的约会,从当前日期到约会日期,我想知道某个特定日期是约会的一周还是约会的一个月。
var startDate = startDate
let calendar = Calendar.current
let fmt = DateFormatter()
fmt.dateFormat = "yyyy-MM-dd"
while startDate <= endDate {
var newDate = calendar.date(byAdding: .day, value: 1, to: startDate)!
if newDate is a month to endDate {
//schedule reminder
}
if newDate is a week to endDate{
//schedule reminder
}
我如何检查当前日期是否是约会的一周/一个月?
【问题讨论】: