From 0fcf46f8d7c2bca8134b2a383374ec7258a3f898 Mon Sep 17 00:00:00 2001 From: solid-maksymtielnyi Date: Fri, 6 Dec 2024 02:04:17 +0200 Subject: [PATCH] Add AM/PM marker if 12-hour time format does not contain it Fixes https://github.com/Nikoro/system_date_time_format/issues/23 --- lib/system_date_time_format.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/system_date_time_format.dart b/lib/system_date_time_format.dart index 245597f..fae7a1d 100644 --- a/lib/system_date_time_format.dart +++ b/lib/system_date_time_format.dart @@ -60,7 +60,16 @@ class SystemDateTimeFormat { Future getTimePattern() async { final pattern = await SystemDateTimeFormatPlatformInterface.instance.getTimePattern(); - return pattern.isNullOrEmpty ? null : pattern; + + if (pattern.isNullOrEmpty) return null; + + // Add an AM/PM marker if the 12-hour time pattern does not contain it. + // Fixes https://github.com/Nikoro/system_date_time_format/issues/23 + if (pattern == 'h:mm' || pattern == 'hh:mm') { + return '$pattern a'; + } + + return pattern; } /// Returns all available date & time patterns.