Skip to content

Commit c2374bb

Browse files
committed
showing date too when not today
1 parent 453171c commit c2374bb

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

BeeSwift/GoalViewController.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,19 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
359359
}
360360

361361
private func refreshPullDown() {
362-
let lastSynced = goal.lastSyncedWithHealthKit?
363-
.formatted(date: .omitted, time: .shortened)
364-
?? "not yet"
362+
let lastSynced: String = {
363+
guard
364+
let lastSyncedWithHealthKit = goal.lastSyncedWithHealthKit
365+
else { return "not yet" }
366+
367+
let isSameDay = Calendar.autoupdatingCurrent.isDate(lastSyncedWithHealthKit,
368+
inSameDayAs: .now)
369+
let dateStyle: Date.FormatStyle.DateStyle = isSameDay ? .omitted : .numeric
370+
371+
return lastSyncedWithHealthKit
372+
.formatted(date: dateStyle,
373+
time: .shortened)
374+
}()
365375

366376
if self.goal.isLinkedToHealthKit {
367377
pullToRefreshView.message = "Pull down to synchronize with Apple Health"

0 commit comments

Comments
 (0)