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.

24 lines
545 B

  1. //
  2. // Date+Ext.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 15/07/2019.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. extension Date {
  10. static func - (lhs: Date, rhs: Date) -> Int? {
  11. let calendar = Calendar.current
  12. let startDate = calendar.startOfDay(for: rhs)
  13. let endDate = calendar.startOfDay(for: lhs)
  14. guard let remindDay = calendar.dateComponents([.day], from: startDate, to: endDate).day else {
  15. return nil
  16. }
  17. return remindDay
  18. }
  19. }