From 6e401c6bd31b276b3248505120fd366eec5002ae Mon Sep 17 00:00:00 2001 From: Oleg Date: Sat, 6 Jan 2024 17:19:05 +0300 Subject: [PATCH] add lesson date for ios widget if lesson is not today --- ios/UWidget/UWidget.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ios/UWidget/UWidget.swift b/ios/UWidget/UWidget.swift index 8a02d1e..d96af65 100644 --- a/ios/UWidget/UWidget.swift +++ b/ios/UWidget/UWidget.swift @@ -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) }