Skip to content

Commit

Permalink
Emit createdDate and lastModifiedDate in JSON-format output. (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spirotot authored Aug 4, 2024
1 parent 7bd8624 commit 1adaee7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/RemindersLibrary/EKReminder+Encodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import EventKit
extension EKReminder: Encodable {
private enum EncodingKeys: String, CodingKey {
case externalId
case lastModified
case creationDate
case title
case notes
case url
Expand Down Expand Up @@ -48,6 +50,14 @@ extension EKReminder: Encodable {
if let dueDateComponents = self.dueDateComponents {
try container.encodeIfPresent(format(dueDateComponents.date), forKey: .dueDate)
}

if let lastModifiedDate = self.lastModifiedDate {
try container.encode(format(lastModifiedDate), forKey: .lastModified)
}

if let creationDate = self.creationDate {
try container.encode(format(creationDate), forKey: .creationDate)
}
}

private func format(_ date: Date?) -> String? {
Expand Down

0 comments on commit 1adaee7

Please sign in to comment.