Skip to content

Commit

Permalink
Merge pull request #3535 from atjn/meridian-fix-1
Browse files Browse the repository at this point in the history
Improve support for meridians
  • Loading branch information
gfwilliams authored Aug 27, 2024
2 parents b558052 + 332d3ca commit 43893ba
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/locale/locale.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,14 @@
var p = Math.max(0,Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10))));
return n.toFixed(p);
}
var is12;
var _is12Hours;
function is12Hours() {
if (_is12Hours === undefined) _is12Hours = ${isLocal ? "false" : `(require('Storage').readJSON('setting.json', 1) || {})["12hour"]`};
return _is12Hours;
}
function getHours(d) {
var h = d.getHours();
if (is12 === undefined) is12 = ${isLocal ? "false" : `(require('Storage').readJSON('setting.json', 1) || {})["12hour"]`};
if (!is12) return ('0' + h).slice(-2);
if (!is12Hours()) return ('0' + h).slice(-2);
return ((h % 12 == 0) ? 12 : h % 12).toString();
}
exports = {
Expand Down Expand Up @@ -234,7 +237,8 @@
translate: s => ${locale.trans?`{var t=${js(locale.trans)};s=''+s;return t[s]||t[s.toLowerCase()]||s;}`:`s`},
date: (d,short) => short ? \`${dateS}\` : \`${dateN}\`,
time: (d,short) => short ? \`${timeS}\` : \`${timeN}\`,
meridian: d => d.getHours() < 12 ? ${js(locale.ampm[0])}:${js(locale.ampm[1])},
meridian: d => is12Hours() ? d.getHours() < 12 ? ${js(locale.ampm[0])}:${js(locale.ampm[1])} : "",
is12Hours,
};
`.trim()
};
Expand Down

0 comments on commit 43893ba

Please sign in to comment.