Skip to content

Commit 10b2e9e

Browse files
committed
Only return meridian for 12-hour clocks
1 parent 84aabfa commit 10b2e9e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

apps/locale/locale.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,14 @@
204204
var p = Math.max(0,Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10))));
205205
return n.toFixed(p);
206206
}
207-
var is12;
207+
var _is12Hours;
208+
function is12Hours() {
209+
if (_is12Hours === undefined) _is12Hours = ${isLocal ? "false" : `(require('Storage').readJSON('setting.json', 1) || {})["12hour"]`};
210+
return _is12Hours;
211+
}
208212
function getHours(d) {
209213
var h = d.getHours();
210-
if (is12 === undefined) is12 = ${isLocal ? "false" : `(require('Storage').readJSON('setting.json', 1) || {})["12hour"]`};
211-
if (!is12) return ('0' + h).slice(-2);
214+
if (!is12Hours()) return ('0' + h).slice(-2);
212215
return ((h % 12 == 0) ? 12 : h % 12).toString();
213216
}
214217
exports = {
@@ -237,7 +240,7 @@
237240
translate: s => ${locale.trans?`{var t=${js(locale.trans)};s=''+s;return t[s]||t[s.toLowerCase()]||s;}`:`s`},
238241
date: (d,short) => short ? \`${dateS}\` : \`${dateN}\`,
239242
time: (d,short) => short ? \`${timeS}\` : \`${timeN}\`,
240-
meridian: d => d.getHours() < 12 ? ${js(locale.ampm[0])}:${js(locale.ampm[1])},
243+
meridian: d => is12Hours() ? d.getHours() < 12 ? ${js(locale.ampm[0])}:${js(locale.ampm[1])} : "",
241244
};
242245
`.trim()
243246
};

0 commit comments

Comments
 (0)