interval-timer-ios/IntervalTimer/Extensions.swift
William Brawner e73a8b198e Build out most of the UI and functionality
Kinda forgot to commit as I went. Better late than never I guess
2020-11-01 11:54:19 -07:00

38 lines
847 B
Swift

//
// Extensions.swift
// IntervalTimer
//
// Created by William Brawner on 10/23/20.
// Copyright © 2020 William Brawner. All rights reserved.
//
import Foundation
import SwiftUI
extension View {
func toAnyView() -> AnyView {
return AnyView(self)
}
}
extension Int64 {
func toDurationString() -> String {
var seconds: Int64 = self
var hours: Int64 = 0
if (seconds >= 3600) {
hours = seconds / 3600
seconds -= hours * 3600
}
var minutes: Int64 = 0
if (seconds >= 60) {
minutes = seconds / 60
seconds -= minutes * 60
}
if hours > 0 {
return String(format: "%02d:%02d:%02d", hours, minutes, seconds)
}
return String(format: "%02d:%02d", minutes, seconds)
}
}