Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update locale with support for meridians #2540

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions libs/js/banglejs/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ function round(n, dp) {
var p = Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10)));
return n.toFixed(p);
}
var _is12Hours;
function is12Hours() {
if (_is12Hours === undefined) _is12Hours = (require('Storage').readJSON('setting.json',1)||{})["12hour"];
return _is12Hours;
}
exports = { name : "system", currencySym:"£",
translate : str=>str, // as-is
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)
time : (d,short) => { // Date to "4:15.28 pm" or "15:42"(short)
var h = d.getHours(), m = d.getMinutes()
if ((require('Storage').readJSON('setting.json',1)||{})["12hour"])
if (is12Hours())
h = (h%12==0) ? 12 : h%12; // 12 hour
if (short)
return (" "+h).substr(-2)+":"+("0"+m).substr(-2);
Expand Down Expand Up @@ -42,5 +47,6 @@ exports = { name : "system", currencySym:"£",
distance : (m,dp) => (m<1000)?round(m,dp)+"m":round(m/1000,dp)+"km", // meters to "123m" or "1.2km" depending on size
speed : (s,dp) => round(s/1.60934,dp)+"mph",// kph to "123mph"
temp : (t,dp) => round(t,dp)+"'C", // degrees C to degrees C
meridian: d => (d.getHours() <= 12) ? "am":"pm" // Date to am/pm
meridian: d => is12Hours() ? (d.getHours() <= 12) ? "am":"pm" : "", // Date to am/pm
is12Hours,
};
6 changes: 3 additions & 3 deletions libs/js/banglejs/locale.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading