# HG changeset patch # User Edouard Tisserant # Date 1653465170 -7200 # Node ID 0d5bb9038e5b2854f5b910495462e992b530d70f # Parent 5f417d3c2d035c7cc1a7ce312416b444be9ad141 SVGHMI: prevent exception with date/time formating in sprintf.js if lang wasn't already set. diff -r 5f417d3c2d03 -r 0d5bb9038e5b svghmi/sprintf.js --- a/svghmi/sprintf.js Wed May 25 09:51:22 2022 +0200 +++ b/svghmi/sprintf.js Wed May 25 09:52:50 2022 +0200 @@ -114,8 +114,14 @@ /* get lang from globals */ let lang = get_current_lang_code(); - arg = Date(arg).toLocaleString('en-US', options); - + let f; + try{ + f = new Intl.DateTimeFormat(lang, options); + } catch(e) { + f = new Intl.DateTimeFormat('en-US', options); + } + arg = f.format(arg); + /* TODO: select with padding char a: absolute time and date (default)