From ebd8b700b10ee9693ad194382d2b3faeef3de892 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sun, 11 Aug 2024 12:31:10 +0200 Subject: [PATCH] chore: Show short forms of months and week days in UI --- lib/utils/date_time_extension.dart | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/utils/date_time_extension.dart b/lib/utils/date_time_extension.dart index 13bae4efa..0346dd289 100644 --- a/lib/utils/date_time_extension.dart +++ b/lib/utils/date_time_extension.dart @@ -56,19 +56,14 @@ extension DateTimeExtension on DateTime { if (sameDay) { return localizedTimeOfDay(context); } else if (sameWeek) { - return DateFormat.EEEE(Localizations.localeOf(context).languageCode) + return DateFormat.E(Localizations.localeOf(context).languageCode) .format(this); } else if (sameYear) { - return L10n.of(context)!.dateWithoutYear( - month.toString().padLeft(2, '0'), - day.toString().padLeft(2, '0'), - ); + return DateFormat.MMMd(Localizations.localeOf(context).languageCode) + .format(this); } - return L10n.of(context)!.dateWithYear( - year.toString(), - month.toString().padLeft(2, '0'), - day.toString().padLeft(2, '0'), - ); + return DateFormat.yMMMd(Localizations.localeOf(context).languageCode) + .format(this); } /// If the DateTime is today, this returns [localizedTimeOfDay()], if not it also