From c1e49ed66f58edcbc4732a7fabb58a9890dbd957 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 17 Jan 2021 13:51:21 -0500 Subject: [PATCH] [+] Create function to get hour, minute, second from date --- ProjectClock/Utils.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ProjectClock/Utils.swift b/ProjectClock/Utils.swift index e7ee162..b5b8021 100644 --- a/ProjectClock/Utils.swift +++ b/ProjectClock/Utils.swift @@ -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!) + } }