From fbef914604fae8c388e171f306dfe47e39b9bfc8 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Thu, 21 Mar 2024 20:11:17 +0100 Subject: [PATCH] locale: fix trailing space on date < 10 The trailing whitespace would make the date string look uncentered on e.g. `antonclk` clock app on Bangle.js. Possibly similar change should be made to the `locale` library of espruino/BangleApps - but I'm not sure. --- libs/js/banglejs/locale.js | 2 +- libs/js/banglejs/locale.min.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/js/banglejs/locale.js b/libs/js/banglejs/locale.js index edddec44a4..a46c09cd4d 100644 --- a/libs/js/banglejs/locale.js +++ b/libs/js/banglejs/locale.js @@ -5,7 +5,7 @@ function round(n, dp) { } 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), // Date to "Feb 28 2020" or "28/02/2020"(short) + 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"]) diff --git a/libs/js/banglejs/locale.min.js b/libs/js/banglejs/locale.min.js index bce595a8b2..4ad686d71d 100644 --- a/libs/js/banglejs/locale.min.js +++ b/libs/js/banglejs/locale.min.js @@ -1,3 +1,3 @@ -function d(a,b){void 0===b&&(b=1);return a.toFixed(Math.min(b,b-Math.floor(Math.log(a)/Math.log(10))))}exports={name:"system",currencySym:"\xa3",translate:a=>a,date:(a,b)=>b?("0"+a.getDate()).substr(-2)+"/"+("0"+(a.getMonth()+1)).substr(-2)+"/"+a.getFullYear():a.toString().substr(4,11),time:(a,b)=>{var c=a.getHours(),e=a.getMinutes();(require("Storage").readJSON("setting.json",1)||{})["12hour"]&&(c=0==c%12?12:c%12);if(b)return(" "+c).substr(-2)+":"+("0"+e).substr(-2);b= +function d(a,b){void 0===b&&(b=1);return a.toFixed(Math.min(b,b-Math.floor(Math.log(a)/Math.log(10))))}exports={name:"system",currencySym:"\xa3",translate:a=>a,date:(a,b)=>b?("0"+a.getDate()).substr(-2)+"/"+("0"+(a.getMonth()+1)).substr(-2)+"/"+a.getFullYear():a.toString().substr(4,11).trim(),time:(a,b)=>{var c=a.getHours(),e=a.getMinutes();(require("Storage").readJSON("setting.json",1)||{})["12hour"]&&(c=0==c%12?12:c%12);if(b)return(" "+c).substr(-2)+":"+("0"+e).substr(-2);b= "am";0==c?c=12:12<=c&&(12"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" ")[a.getDay()].substr(0,b?3:10),month:(a,b)=>"January February March April May June July August September October November December".split(" ")[a.getMonth()].substr(0,b?3:10),number:a=>a.toString(),currency:a=>"\xa3"+a.toFixed(2),distance:(a,b)=>1E3>a?d(a,b)+"m":d(a/1E3,b)+"km",speed:(a, -b)=>d(a/1.60934,b)+"mph",temp:(a,b)=>d(a,b)+"'C",meridian:a=>12>=a.getHours()?"am":"pm"} \ No newline at end of file +b)=>d(a/1.60934,b)+"mph",temp:(a,b)=>d(a,b)+"'C",meridian:a=>12>=a.getHours()?"am":"pm"}