Skip to content

Commit

Permalink
fix: fix 12hour browser time format detection (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Nov 23, 2023
1 parent e8755fa commit c36bfe6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/store/gui/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ export const getters: GetterTree<GuiState, any> = {
const setting = state.general.timeFormat
if (setting === '12hours') return true
if (setting === null) {
// create a time string, cut the last 2 chars and check if it contains AM or PM
const timeString = new Date().toLocaleString(navigator.language, { timeStyle: 'short' }).slice(-2)
if (['AM', 'PM'].includes(timeString)) return true
return Intl.DateTimeFormat(navigator.language, { hour: 'numeric' }).resolvedOptions().hour12
}

return false
Expand Down

0 comments on commit c36bfe6

Please sign in to comment.