From 6b89b930fc8f957bb66e824b95086dacf4bbbc80 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 17 Jan 2021 13:25:04 -0500 Subject: [PATCH] [+] Add toString to Date --- ProjectClock.xcodeproj/project.pbxproj | 4 ++++ ProjectClock/Utils.swift | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 ProjectClock/Utils.swift diff --git a/ProjectClock.xcodeproj/project.pbxproj b/ProjectClock.xcodeproj/project.pbxproj index 6ce5cd7..b016d1a 100644 --- a/ProjectClock.xcodeproj/project.pbxproj +++ b/ProjectClock.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 4F98955225A9260400F51321 /* Net.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F98955125A9260400F51321 /* Net.swift */; }; 4FA419AF25AF93EC004CE0FC /* AlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */; }; 4FD642D325B48C380069171E /* AlarmActivator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FD642D225B48C380069171E /* AlarmActivator.swift */; }; + 4FD642DB25B4B7F60069171E /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FD642DA25B4B7F60069171E /* Utils.swift */; }; 4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0683E25A5F18700304E6B /* AppDelegate.swift */; }; 4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684025A5F18700304E6B /* SceneDelegate.swift */; }; 4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684225A5F18700304E6B /* AccountViewController.swift */; }; @@ -29,6 +30,7 @@ 4F98955125A9260400F51321 /* Net.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Net.swift; sourceTree = ""; }; 4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmViewController.swift; sourceTree = ""; }; 4FD642D225B48C380069171E /* AlarmActivator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmActivator.swift; sourceTree = ""; }; + 4FD642DA25B4B7F60069171E /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; 4FF0683B25A5F18700304E6B /* ProjectClock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProjectClock.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4FF0683E25A5F18700304E6B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4FF0684025A5F18700304E6B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -91,6 +93,7 @@ 4F509BD125AE22D100726227 /* Models.swift */, 7C83963825AF68980027A94C /* TestingViewController.swift */, 4FD642D225B48C380069171E /* AlarmActivator.swift */, + 4FD642DA25B4B7F60069171E /* Utils.swift */, ); path = ProjectClock; sourceTree = ""; @@ -184,6 +187,7 @@ 4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */, 4FD642D325B48C380069171E /* AlarmActivator.swift in Sources */, 4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */, + 4FD642DB25B4B7F60069171E /* Utils.swift in Sources */, 4FA419AF25AF93EC004CE0FC /* AlarmViewController.swift in Sources */, 4F509BD225AE22D100726227 /* Models.swift in Sources */, 7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */, diff --git a/ProjectClock/Utils.swift b/ProjectClock/Utils.swift new file mode 100644 index 0000000..7f0f8bb --- /dev/null +++ b/ProjectClock/Utils.swift @@ -0,0 +1,19 @@ +// +// Utils.swift +// ProjectClock +// +// Created by Hykilpikonna on 1/17/21. +// + +import Foundation + +extension Date +{ + /// Add toString to Date + func str() -> String + { + let f = DateFormatter() + f.dateFormat = "yyyy-MM-dd hh:mm:ss" + return f.string(from: self) + } +}