为什么 'nextDateAfterDate' 功能没有按预期工作?

Why is 'nextDateAfterDate' function not working as expected?

我在 XCode 游乐场中有以下代码:

let currentDate = NSDate()

var starttime = NSCalendar.currentCalendar().nextDateAfterDate(currentDate, matchingUnit: NSCalendarUnit.Minute, value: 15, options: NSCalendarOptions.MatchNextTime)

如果 currentDate 是“2016-01-03 03:57 +0100”,则开始时间正确设置为 "Jan 3, 2016, 4:15 AM",但如果 currentDate 是“2016-01-03 03:56 +0100 " 开始时间错误地设置为 "Jan 4, 2016, 12:00 AM"。我不知道怎么了。我是不是忽略了什么?

我无法解释意外行为,但将匹配选项设置为

[.MatchNextTime, .MatchStrictly]

解决了问题并在我的所有测试中给出了正确的结果。

.MatchStrictly 记录为

Specifies that the operation should travel as far forward or backward as necessary looking for a match.