From 3716195e51096237dba8691c197103c8f8abe587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Jime=CC=81nez=20Agudo?= Date: Sat, 25 Feb 2017 19:21:05 +0100 Subject: [PATCH] - New: Converts a Date to a string with ISO format by default --- Source/GIGUtils/Date/NSDate+GIGExtension.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/GIGUtils/Date/NSDate+GIGExtension.swift b/Source/GIGUtils/Date/NSDate+GIGExtension.swift index cb8c41a..df9830f 100644 --- a/Source/GIGUtils/Date/NSDate+GIGExtension.swift +++ b/Source/GIGUtils/Date/NSDate+GIGExtension.swift @@ -44,6 +44,14 @@ public extension Date { return Date() } + public func string(with format: String = DateISOFormat) -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = format + dateFormatter.amSymbol = "" + dateFormatter.pmSymbol = "" + return dateFormatter.string(from: self) + } + /** Set the time to a NSDate