Last active
February 19, 2017 14:19
-
-
Save srdanrasic/051ae4cc859106e5732837a87a4fa0ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct LocalDate { | |
public let day: Int | |
public let month: Int | |
public let year: Int | |
public init(day: Int, month: Int, year: Int) { | |
self.day = day | |
self.month = month | |
self.year = year | |
} | |
} | |
extension LocalDate { | |
public init(date: Date, calendar: Calendar = Calendar.current) { | |
let components = calendar.dateComponents([.day, .month, .year], from: date) | |
day = components.day! | |
month = components.month! | |
year = components.year! | |
} | |
} | |
extension LocalDate: Equatable { | |
public static func ==(lhs: LocalDate, rhs: LocalDate) -> Bool { | |
return lhs.day == rhs.day && lhs.month == rhs.month && lhs.year == rhs.year | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment