LGV_CleantimeDateCalc
public struct LGV_CleantimeDateCalc
This is the fundamental core of the recovery time calculator. All the action happens in the designated initializer. Once the struct is instantiated, its work is done. Most clients will use it by retrieving the “cleanTime” property, which will provide interpretations of the dates.
This will not work with starting dates earlier than Jan 1, 1950.
The algorithm is non-inclusive. It does not count the initial day. If the start date and end date are the same, zero days have passed.
The granularity of the algorithm is complete days. The start time and end time are assumed to be noon.
This uses the Gregorian calendar by default, but the calendar can be changed.
-
This enum is used as the response from the lastCleantimeMilestone computed property. This denotes the milestones that we use in NA.
See moreDeclaration
Swift
public enum CleanTimeEvent : Equatable
-
This is the designated initializer. It takes two dates, and calculates between them.
Declaration
Parameters
startDate
This is the “from” date. It is the start of the calculation. If not given, then an invalid date is assumed, and the result will be zero.
endDate
This is the end date. The calculation goes between these two dates. This can be omitted, in which case, today is assumed.
calendar
An optional calendar instance (default is nil). If nil, Gregorian is used.
-
This is a basic struct that contains the components, but in a simpler, read-only, form.
This is what most clients will use, as it also offers interpretations.
See moreDeclaration
Swift
public struct Cleantime
-
This returns the cleantime, in the simple read-only struct form.
Declaration
Swift
var cleanTime: Cleantime { get }
-
The starting date of the period (the cleandate).
Declaration
Swift
var startDate: Date? { get }
-
The ending date of the period (today, usually).
Declaration
Swift
var endDate: Date? { get }
-
The last cleantime event. Returns an enum, with the last “milestone” achieved, as of the end date.
Declaration
Swift
var lastCleantimeMilestone: CleanTimeEvent { get }
-
The next cleantime event. Returns an enum, with the next “milestone” to be achieved.
Note
This will not “predict” major annual milestones, like twenty years, or forty years, unless that milestone is iminent (the next year, or, in the case of 10,000 days, the next 27.4 year milestone). Otherwise, it will return regular annual milestones.
Declaration
Swift
var nextCleantimeMilestone: CleanTimeEvent { get }
-
The last cleantime event. Returns the date that the last cleantime milestone was met. Nil, if invalid.
Declaration
Swift
var dateOfLastCleantimeMilestone: Date? { get }
-
The last cleantime event. Returns the date that the next cleantime milestone will be met. Nil, if invalid.
Declaration
Swift
var dateOfNextCleantimeMilestone: Date? { get }
-
Declaration
Swift
var dateOfLastAnnualMilestone: Date? { get }
Return Value
The date, or nil, of the last yearly milestone (if less than 1 year since the initial date, then this returns nil)
-
Returns the date of the milestone this many days from the start.
Declaration
Swift
func daysFromStart(_ inDays: Int) -> Date?
Parameters
inDays
The number of days to calculate from the start.
Return Value
The date (or nil, if it is undefined).
-
Returns the date of the milestone this many months from the start.
Declaration
Swift
func monthsFromStart(_ inMonths: Int) -> Date?
Parameters
inMonths
The number of months to calculate from the start.
Return Value
The date (or nil, if it is undefined).
-
Returns the date of the milestone this many years from the start.
Declaration
Swift
func yearsFromStart(_ inYears: Int) -> Date?
Parameters
inYears
The number of years to calculate from the start.
Return Value
The date (or nil, if it is undefined).
-
This will return the exact date that a particular milestone was/will be reached.
Declaration
Swift
func dateOfThisCleantimeMilestone(_ inCleantimeMilestone: CleanTimeEvent) -> Date?
Parameters
inCleantimeMileStone
The enum, specifying the milestone to test.
Return Value
The date, or nil, if the milestone (or this struct) is invalid.
-
Returns the cleantime in standard Date Components form.
Declaration
Swift
var components: DateComponents { get }
-
Returns the cleantime as a Time Interval
Declaration
Swift
var timeInterval: TimeInterval? { get }