Writing a simple date extension:
extension Date {
public func removeTimeStamp() -> Date {
guard let date = Calendar.current.date(from: Calendar.current.dateComponents([.year, .month, .day], from: self)) else {
fatalError("Failed to strip time from Date object")
}
return date
}
}
I get:
2020-11-11 13:00:00 +0000
Notice again it has added an hour, but to the afternoon, not the morning even.
I would expect
2020-11-11 00:00:00 +0000
EDIT: Focused question on the date truncation component