Is there a way to create a Date constant from year, month and day? The only constructors that show up are .now and those based on some timeInterval. I'm trying to initialize some test data with known dates.
Did you try this:
func makeDate(year: Int, month: Int, day: Int, hr: Int = 0, min: Int = 0, sec: Int = 0) -> Date {
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = TimeZone(identifier: "GMT")!
let components = DateComponents(year: year, month: month, day: day) //, hour: hr, minute: min, second: sec)
return calendar.date(from: components)!
}
let myDate = makeDate(year: 2025, month: 02, day: 10)
print(myDate)