Begin statistics creation
This commit is contained in:
15
CHDataManagement/Workouts/Date+Days.swift
Normal file
15
CHDataManagement/Workouts/Date+Days.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user