fix: fix ETA 12hour detection if the user use default setting (#1657)

This commit is contained in:
Stefan Dej authored and GitHub committed 2023-11-18 23:58:14 +01:00
1 parent 46c9d6f627
commit ec399c2b78
3 files changed
+5 -8

No files matched your search

+1 -5
View File
@@ -183,11 +183,7 @@ export default class BaseMixin extends Vue {
}
get hours12Format() {
const setting = this.$store.state.gui.general.timeFormat
if (setting === '12hours') return true
if (setting === null && this.browserLocale === 'en-US') return true
return false
return this.$store.getters['gui/getHours12Format']
}
formatDate(value: number | Date): string {
+3 -2
View File
@@ -157,8 +157,9 @@ export const getters: GetterTree<GuiState, any> = {
const setting = state.general.timeFormat
if (setting === '12hours') return true
if (setting === null) {
const timestring = new Date().toLocaleTimeString().split(' ')
return timestring.includes('AM') || timestring.includes('PM')
// 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 false
+1 -1
View File
@@ -747,7 +747,7 @@ export const getters: GetterTree<PrinterState, RootState> = {
timeCount++
}
if (time && timeCount) return Date.now() + (time / timeCount) * 1000
if (time && timeCount) return Math.round(Date.now() + (time / timeCount) * 1000)
return 0
},