Skip to content

Commit 43893ba

Browse files
authored
Merge pull request #3535 from atjn/meridian-fix-1
Improve support for meridians
2 parents b558052 + 332d3ca commit 43893ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

apps/locale/locale.html

+8-4
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,14 @@
201201
var p = Math.max(0,Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10))));
202202
return n.toFixed(p);
203203
}
204-
var is12;
204+
var _is12Hours;
205+
function is12Hours() {
206+
if (_is12Hours === undefined) _is12Hours = ${isLocal ? "false" : `(require('Storage').readJSON('setting.json', 1) || {})["12hour"]`};
207+
return _is12Hours;
208+
}
205209
function getHours(d) {
206210
var h = d.getHours();
207-
if (is12 === undefined) is12 = ${isLocal ? "false" : `(require('Storage').readJSON('setting.json', 1) || {})["12hour"]`};
208-
if (!is12) return ('0' + h).slice(-2);
211+
if (!is12Hours()) return ('0' + h).slice(-2);
209212
return ((h % 12 == 0) ? 12 : h % 12).toString();
210213
}
211214
exports = {
@@ -234,7 +237,8 @@
234237
translate: s => ${locale.trans?`{var t=${js(locale.trans)};s=''+s;return t[s]||t[s.toLowerCase()]||s;}`:`s`},
235238
date: (d,short) => short ? \`${dateS}\` : \`${dateN}\`,
236239
time: (d,short) => short ? \`${timeS}\` : \`${timeN}\`,
237-
meridian: d => d.getHours() < 12 ? ${js(locale.ampm[0])}:${js(locale.ampm[1])},
240+
meridian: d => is12Hours() ? d.getHours() < 12 ? ${js(locale.ampm[0])}:${js(locale.ampm[1])} : "",
241+
is12Hours,
238242
};
239243
`.trim()
240244
};

0 commit comments

Comments
 (0)