Created
May 12, 2022 17:14
-
-
Save vladimir-anisimov/f4864312a5e7279844981da3f794ae8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension TimeInterval { | |
static var second: TimeInterval { | |
return 1.0 | |
} | |
static var minute: TimeInterval { | |
return second * 60.0 | |
} | |
static var hour: TimeInterval { | |
return minute * 60 | |
} | |
static var day: TimeInterval { | |
return hour * 24 | |
} | |
static func seconds(_ number: Int) -> TimeInterval { | |
return Self.second * Double(number) | |
} | |
static func minutes(_ number: Int) -> TimeInterval { | |
return Self.minute * Double(number) | |
} | |
static func hours(_ number: Int) -> TimeInterval { | |
return Self.hour * Double(number) | |
} | |
static func days(_ number: Int) -> TimeInterval{ | |
return Self.day * Double(number) | |
} | |
func hours() -> Int { | |
return Int(Double(self) / 60.0 / 60.0 ) | |
} | |
func minutes() -> Int { | |
Int(Double(self) / 60.0 ) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment