Template scripts: new Date().toLocaleDateString() not working properly



  • VERSION: jsreport.exe v.1.10

    I have the template and right below the template I'm having few scripts, e.g.

    function format_date(d) {
        if (!d) {
            return '';
        }
        var options = { day: '2-digit', month: '2-digit' };
        return (new Date(d)).toLocaleDateString('en-AU', options);
    }
    

    but this is giving me the incorrect locale string:

    Wednesday, February 28, 2018

    If I run exactly the same thing in my chrome browser or in the nodejs, with the full-icu package installed and with correct environment variable (NODE_ICU_DATA) I get:

    '28/02'

    Which is correct.

    How can I get the full locale support available for the functions declared in the template? I reckon it's that snapshot of chrome you are packaging... Thanks for any help here.

    VERSION: jsreport (node) v.2.1
    In this version I'm getting a slightly better result, but still not right as the day should be first

    '02/28'



  • The jsreport.exe is compiled with normal node without extra localization. I am not sure how the size would grow if we would compile the localization there.

    I believe we should get it running with full node and the arg NODE_ICU_DATA as you get it working in normal node.
    The problem could be that we fork extra process for templating engine evaluation and this process doesn't get the NODE_ICU_DATA propagated.
    Could you please try to change the config in v2 as this and try again with NODE_ICU_DATA set?

    "templatingEngines": {
        "timeout": 10000,
        "strategy": "in-process"
      }
    

    This would make templating engines running in the same node process.
    I would try myself but wasn't able to quickly find that intl file, maybe you can link it here. Thanks.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.