Last active
September 17, 2018 16:55
-
-
Save vialyx/8f0b773c1474ecc7f7210a28d900f670 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 Date { | |
func get(_ unit: Calendar.Component) -> Int { | |
return Calendar.current.component(unit, from: self) | |
} | |
var hour: Int { | |
return get(.hour) | |
} | |
} | |
let today = Date(timeIntervalSinceNow: 1 * 60 * 60) // Sep 17, 2018 at 8:55 PM | |
let hours = today.hour // 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment