// // Date+Ext.swift // GME Remit // // Created by InKwon James Kim on 15/07/2019. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. // import Foundation extension Date { static func - (lhs: Date, rhs: Date) -> Int? { let calendar = Calendar.current let startDate = calendar.startOfDay(for: rhs) let endDate = calendar.startOfDay(for: lhs) guard let remindDay = calendar.dateComponents([.day], from: startDate, to: endDate).day else { return nil } return remindDay } } extension Date { func asString(style: DateFormatter.Style) -> String { let dateFormatter = DateFormatter() dateFormatter.dateStyle = style return dateFormatter.string(from: self) } func converToString(dateFormat format: String) -> String { let dateFormatter = DateFormatter() dateFormatter.dateFormat = format return dateFormatter.string(from: self) } }