[+] Create function to get hour, minute, second from date

This commit is contained in:
Hykilpikonna
2021-01-17 13:51:21 -05:00
parent bf37dd657c
commit c1e49ed66f
+8
View File
@@ -37,4 +37,12 @@ extension Date
let comp = calendar.dateComponents([.year, .month, .day], from: self)
return (comp.year!, comp.month!, comp.day!)
}
/// Get hour, minute, seconds
func getHMS() -> (h: Int, m: Int, s: Int)
{
let calendar = Calendar.current
let comp = calendar.dateComponents([.hour, .minute, .second], from: self)
return (comp.hour!, comp.minute!, comp.second!)
}
}