Skip to content

Commit 9af1331

Browse files
committed
Update locale with support for meridians
1 parent ff487e0 commit 9af1331

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libs/js/banglejs/locale.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ function round(n, dp) {
33
var p = Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10)));
44
return n.toFixed(p);
55
}
6+
var _is12Hours;
7+
function is12Hours() {
8+
if (_is12Hours === undefined) _is12Hours = (require('Storage').readJSON('setting.json',1)||{})["12hour"];
9+
return _is12Hours;
10+
}
611
exports = { name : "system", currencySym:"£",
712
translate : str=>str, // as-is
813
date : (d,short) => short?("0"+d.getDate()).substr(-2)+"/"+("0"+(d.getMonth()+1)).substr(-2)+"/"+d.getFullYear():d.toString().substr(4,11).trim(), // Date to "Feb 28 2020" or "28/02/2020"(short)
914
time : (d,short) => { // Date to "4:15.28 pm" or "15:42"(short)
1015
var h = d.getHours(), m = d.getMinutes()
11-
if ((require('Storage').readJSON('setting.json',1)||{})["12hour"])
16+
if (is12Hours())
1217
h = (h%12==0) ? 12 : h%12; // 12 hour
1318
if (short)
1419
return (" "+h).substr(-2)+":"+("0"+m).substr(-2);
@@ -42,5 +47,6 @@ exports = { name : "system", currencySym:"£",
4247
distance : (m,dp) => (m<1000)?round(m,dp)+"m":round(m/1000,dp)+"km", // meters to "123m" or "1.2km" depending on size
4348
speed : (s,dp) => round(s/1.60934,dp)+"mph",// kph to "123mph"
4449
temp : (t,dp) => round(t,dp)+"'C", // degrees C to degrees C
45-
meridian: d => (d.getHours() <= 12) ? "am":"pm" // Date to am/pm
50+
meridian: d => is12Hours() ? (d.getHours() <= 12) ? "am":"pm" : "", // Date to am/pm
51+
is12Hours,
4652
};

0 commit comments

Comments
 (0)