Skip to content

Commit

Permalink
add lesson date for ios widget if lesson is not today
Browse files Browse the repository at this point in the history
  • Loading branch information
smart7even committed Jan 6, 2024
1 parent fa75fc4 commit 6e401c6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ios/UWidget/UWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ struct UWidgetEntryView : View {
func formatTime(date: Date) -> String {
let formatter = DateFormatter()
formatter.timeStyle = .short
formatter.dateStyle = .none

if Calendar.current.isDateInToday(date) {
// If the date is today, do not show the date part
formatter.dateFormat = "HH:mm"
} else {
// If the date is not today, include the date part
formatter.dateFormat = "dd.MM, HH:mm"
}

return formatter.string(from: date)
}

Expand Down

0 comments on commit 6e401c6

Please sign in to comment.