There are similar questions but all of them about adding integer number of days to date. But what if I need to add 0.5 day for example?
In other words the following code won't work
let days: Double = 0.5
let date = Calendar.current.date(byAdding: .day, value: days, to: Date())
because:
public func date(byAdding components: DateComponents, to date: Date, wrappingComponents: Bool = false) -> Date?
public func date(byAdding component: Calendar.Component, value: Int, to date: Date, wrappingComponents: Bool = false) -> Date?
public struct DateComponents : ReferenceConvertible, Hashable, Equatable, Sendable {
...
public init(calendar: Calendar? = nil, timeZone: TimeZone? = nil, era: Int? = nil, year: Int? = nil, month: Int? = nil, day: Int? = nil, hour: Int? = nil, minute: Int? = nil, second: Int? = nil, nanosecond: Int? = nil, weekday: Int? = nil, weekdayOrdinal: Int? = nil, quarter: Int? = nil, weekOfMonth: Int? = nil, weekOfYear: Int? = nil, yearForWeekOfYear: Int? = nil)
...
}
int values everywhere only