Skip to content

Commit

Permalink
Add AM/PM marker if 12-hour time format does not contain it
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
solid-maksymtielnyi committed Dec 6, 2024
1 parent 42ae1c1 commit 0fcf46f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/system_date_time_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ class SystemDateTimeFormat {
Future<String?> 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.
Expand Down

0 comments on commit 0fcf46f

Please sign in to comment.