From ca19e9fb1b771384674d10c93bb8d185abff60ee Mon Sep 17 00:00:00 2001 From: Sorunome Date: Wed, 23 Sep 2020 18:26:04 +0200 Subject: [PATCH] fix: determine 12h/24h time based on settings, not locale --- lib/utils/date_time_extension.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/utils/date_time_extension.dart b/lib/utils/date_time_extension.dart index 5d94346..e38544d 100644 --- a/lib/utils/date_time_extension.dart +++ b/lib/utils/date_time_extension.dart @@ -34,8 +34,11 @@ extension DateTimeExtension on DateTime { /// Returns a simple time String. /// TODO: Add localization String localizedTimeOfDay(BuildContext context) { - return L10n.of(context).timeOfDay(_z(hour % 12 == 0 ? 12 : hour % 12), - _z(hour), _z(minute), hour > 11 ? 'pm' : 'am'); + if (MediaQuery.of(context).alwaysUse24HourFormat) { + return '${_z(hour)}:${_z(minute)}'; + } else { + return '${_z(hour % 12 == 0 ? 12 : hour % 12)}:${_z(minute)} ${hour > 11 ? "pm" : "am"}'; + } } /// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week