oracle / graaljs

GraalJS – A high-performance, ECMAScript compliant, and embeddable JavaScript runtime for Java
https://www.graalvm.org/javascript/
Universal Permissive License v1.0
1.81k stars 190 forks source link

Date.prototype.toLocaleString() gives wrong values #319

Closed puneethps closed 4 years ago

puneethps commented 4 years ago

When we are trying to convert a javascript date object to locale string through the Date.prototype.toLocaleString() the value returned is not right. Attached below is the snippet of code used to test this. `

    String script ="{ var contextVar = {}; var a = 5; b = a+5; let date = new Date(); contextVar.obj3 = date.toLocaleString('en-US', 'Australia/Brisbane') }";
    Context context = null;
    try {
        context = Context.newBuilder().allowHostAccess(HostAccess.ALL).build();
        Value jsBindings = context.getBindings("js");

        Source source = Source.newBuilder("js",script,null).build();

        Value val = context.eval(source);
        Value contextVarVal = jsBindings.getMember("contextVar");

        System.err.println(contextVarVal);  
    } finally {
        if(context != null) {
            context.close();
        }
    }

`

This is with graals version 20.1.0.

puneethps commented 4 years ago

Was able to resolve it by passing js.intl-402 option