You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

41 lines
975 B

//
// 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)
}
}