having a string representing the language (optionally with country info), how can I know if the time should be shown as 12H or 24H ?
for example
is12HFormat('en_EN') // returns true
is12HFormat('es_ES') // returns false
Note that I do not want to use a pipe to show a time in a specific format, just find out if one or the other should be used.
EDIT:
currently using:
private guessIf12HTimeFormat(language: string): boolean {
const date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));
const dateString = date.toLocaleTimeString(language);
return (!!dateString.match(/am|pm/i) || !!date.toString().match(/am|pm/i));
}