From 395a7ecdec3c8ac28b87f49c1ce4725dffcb5352 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 17 Jan 2021 13:48:17 -0500 Subject: [PATCH] [+] Create function to get year, month, day from date --- ProjectClock/Utils.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ProjectClock/Utils.swift b/ProjectClock/Utils.swift index 7f0f8bb..8eb5e01 100644 --- a/ProjectClock/Utils.swift +++ b/ProjectClock/Utils.swift @@ -16,4 +16,12 @@ extension Date f.dateFormat = "yyyy-MM-dd hh:mm:ss" return f.string(from: self) } + + /// Get year, month, day + func getYMD() -> (y: Int, m: Int, d: Int) + { + let calendar = Calendar.current + let comp = calendar.dateComponents([.year, .month, .day], from: self) + return (comp.year!, comp.month!, comp.day!) + } }