locale: Apply 12hour setting to time

Fixes #892
master
Richard de Boer 2021-11-26 21:29:58 +01:00
parent 94f8b4bca7
commit 6220a88d29
3 changed files with 10 additions and 2 deletions

View File

@ -170,7 +170,7 @@
{ {
"id": "locale", "id": "locale",
"name": "Languages", "name": "Languages",
"version": "0.09", "version": "0.10",
"description": "Translations for different countries", "description": "Translations for different countries",
"icon": "locale.png", "icon": "locale.png",
"type": "locale", "type": "locale",

View File

@ -9,3 +9,4 @@
0.07: Improve handling of non-ASCII characters (fix #469) 0.07: Improve handling of non-ASCII characters (fix #469)
0.08: Added Mavigation units and en_NAV 0.08: Added Mavigation units and en_NAV
0.09: Added New Zealand en_NZ 0.09: Added New Zealand en_NZ
0.10: Apply 12hour setting to time

View File

@ -146,7 +146,7 @@ exports = { name : "en_GB", currencySym:"£",
"%-m": "d.getMonth()+1", "%-m": "d.getMonth()+1",
"%d": "('0'+d.getDate()).slice(-2)", "%d": "('0'+d.getDate()).slice(-2)",
"%-d": "d.getDate()", "%-d": "d.getDate()",
"%HH": "('0'+d.getHours()).slice(-2)", "%HH": "('0'+getHours(d)).slice(-2)",
"%MM": "('0'+d.getMinutes()).slice(-2)", "%MM": "('0'+d.getMinutes()).slice(-2)",
"%SS": "('0'+d.getSeconds()).slice(-2)", "%SS": "('0'+d.getSeconds()).slice(-2)",
"%A": "day.split(',')[d.getDay()]", "%A": "day.split(',')[d.getDay()]",
@ -178,6 +178,13 @@ var month = ${js(locale.month + ',' + locale.abmonth)};
function round(n) { function round(n) {
return n < 10 ? Math.round(n * 10) / 10 : Math.round(n); return n < 10 ? Math.round(n * 10) / 10 : Math.round(n);
} }
var is12;
function getHours(d) {
var h = d.getHours();
if (is12==undefined) is12 = (require('Storage',1).readJSON('setting.json')||{})["12hour"];
if (!is12) return h;
return (h%12==0) ? 12 : h%12;
}
exports = { exports = {
name: ${js(locale.lang)}, name: ${js(locale.lang)},
currencySym: ${js(locale.currency_symbol)}, currencySym: ${js(locale.currency_symbol)},