init(countingUpIn:showsHours:maxFieldCount:maxPrecision:)
Creates a timer format style that counts up within the interval you provide.
Declaration
init(countingUpIn interval: Range<Date>, showsHours: Bool = true, maxFieldCount: Int = 3, maxPrecision: Duration = .seconds(1))Parameters
- interval:
The time interval during which the timer counts up.
- showsHours:
If
true, hours appear as a separate element when the elapsed time reaches one hour. Iffalse, minutes accumulate beyond 60. - maxFieldCount:
The maximum number of fields shown at once. With the default of 3, output includes hours, minutes, and seconds. With 2, it shows hours and minutes once the time reaches hours.
- maxPrecision:
The smallest time interval between display updates. Defaults to 1 second.
Discussion
The timer displays the elapsed time, starting from zero and increasing toward the total interval duration.