Files
ChWebsiteApp/CHDataManagement/Workouts/Date+Days.swift
2025-08-31 16:27:32 +02:00

16 lines
393 B
Swift

import Foundation
extension Date {
func inclusiveDays(to other: Date, calendar: Calendar = .current) -> Int {
let startDay = calendar.startOfDay(for: self)
let endDay = calendar.startOfDay(for: other)
guard let days = calendar.dateComponents([.day], from: startDay, to: endDay).day else {
return 0
}
return abs(days) + 1
}
}