--- a/svghmi/sprintf.js Wed Mar 02 11:23:50 2022 +0100
+++ b/svghmi/sprintf.js Thu May 05 10:24:56 2022 +0200
@@ -15,7 +15,7 @@
- placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
+ placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxXD])/, key: /^([a-z_][a-z_\d]*)/i,
key_access: /^\.([a-z_][a-z_\d]*)/i,
index_access: /^\[(\d+)\]/,
@@ -78,6 +78,51 @@
+ select date format with width + select time format with precision + %D => 13:31 AM (default) + %1.1D => 07/07/20, 13:31 AM + %1.2D => 07/07/20, 13:31:55 AM + %2.2D => May 5, 2022, 9:29:16 AM + %3.3D => May 5, 2022 at 9:28:16 AM GMT+2 + %4.4D => Thursday, May 5, 2022 at 9:26:59 AM Central European Summer Time + see meaning of DateTimeFormat's options "datestyle" and "timestyle" in MDN + let [datestyle, timestyle] = [ph.width, ph.precision].map(val => { + if(timestyle === undefined && datestyle === undefined){ + /* get lang from globals */ + let lang = get_current_lang_code(); + arg = Date(arg).toLocaleString('en-US', options); + TODO: select with padding char + a: absolute time and date (default) arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)
--- a/svghmi/svghmi.js Wed Mar 02 11:23:50 2022 +0100
+++ b/svghmi/svghmi.js Thu May 05 10:24:56 2022 +0200
@@ -264,6 +264,11 @@
+// returns en_US, fr_FR or en_UK depending on selected language +function get_current_lang_code(){ + return cache[langcode_local_index]; let current_lang = cache[lang_local_index];
let new_lang = switch_langnum(current_lang);