Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #100 - sorting by recent data works #101

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions BeeSwift/JSONGoal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,20 @@ class JSONGoal {
self.leadtime = json["leadtime"].number!
self.alertstart = json["alertstart"].number!
if let lasttouchString = json["lasttouch"].string {
let formatter = DateFormatter.init()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
if let lasttouchDate = formatter.date(from: lasttouchString) {
self.lasttouch = NSNumber(value: lasttouchDate.timeIntervalSince1970)
let lastTouchDate: Date? = {
if #available(iOS 11.0, *) {
let df = ISO8601DateFormatter()
df.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
return df.date(from: lasttouchString)
} else {
let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
return df.date(from: lasttouchString)
}
}()

if let date = lastTouchDate {
self.lasttouch = NSNumber(value: date.timeIntervalSince1970)
}
}
self.queued = json["queued"].bool!
Expand Down