Skip to content

Instantly share code, notes, and snippets.

@srdanrasic
Last active February 19, 2017 14:19
Show Gist options
  • Save srdanrasic/051ae4cc859106e5732837a87a4fa0ee to your computer and use it in GitHub Desktop.
Save srdanrasic/051ae4cc859106e5732837a87a4fa0ee to your computer and use it in GitHub Desktop.
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