fix: determine 12h/24h time based on settings, not locale

This commit is contained in:
Sorunome 2020-09-23 18:26:04 +02:00
parent cf7934022f
commit ca19e9fb1b
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C

View file

@ -34,8 +34,11 @@ extension DateTimeExtension on DateTime {
/// Returns a simple time String. /// Returns a simple time String.
/// TODO: Add localization /// TODO: Add localization
String localizedTimeOfDay(BuildContext context) { String localizedTimeOfDay(BuildContext context) {
return L10n.of(context).timeOfDay(_z(hour % 12 == 0 ? 12 : hour % 12), if (MediaQuery.of(context).alwaysUse24HourFormat) {
_z(hour), _z(minute), hour > 11 ? 'pm' : 'am'); 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 /// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week