diff --git a/Sources/RemindersLibrary/NaturalLanguage.swift b/Sources/RemindersLibrary/NaturalLanguage.swift index edbf9cb..e38ab3c 100644 --- a/Sources/RemindersLibrary/NaturalLanguage.swift +++ b/Sources/RemindersLibrary/NaturalLanguage.swift @@ -28,15 +28,20 @@ private func components(from string: String) -> DateComponents? { return nil } + var includeTime = true + if match.responds(to: NSSelectorFromString("timeIsSignificant")) { + includeTime = match.value(forKey: "timeIsSignificant") as? Bool ?? true + } else { + print("warning: timeIsSignificant is not available, please report this to keith/reminders-cli") + } + let timeZone = match.timeZone ?? .current let parsedComponents = calendar.dateComponents(in: timeZone, from: date) - if let noon = calendar.date(bySettingHour: 12, minute: 0, second: 0, of: date), - calendar.compare(date, to: noon, toGranularity: .minute) == .orderedSame - { + if includeTime { + return parsedComponents + } else { return calendar.dateComponents(calendarComponents(except: timeComponents), from: date) } - - return parsedComponents } extension DateComponents: ExpressibleByArgument {