-
-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toLocaleDateString format and timezone #557
Comments
Didn't even know that was a thing ... |
Curiously the array functions branch also has a problem getting Array.toLocaleString right for booleans, might be realted... |
How do I stringify a Date object in a specific time zone using Jint? The user has to pick a time, but times show up in the server time zone. I know the user IANA time zone. How can I get the UTC offset of the end-user's time zone in Jint? Once I have that, I can calculate the rest. |
I think Jint parses Dates using the host's locale/culture, being the host is where Jint is running. There is quite a lot of work in all the internationalization side to make it work according to the standard related to:
I think almost, if not all of this AbstractOperations need implementation. I can give this a shot and provide a PR and tests when I find some time. Would that make sense @lahma ? |
Generally I'd prefer using the test suite to strive towards expected behavior so we don't need to do it twice (say it's implemented to output X and spec says Y and we don't catch it). When opening new set of tests in test suite we can always add ignore rules that will work as TODO list. Otherwise everything needs to be tested against NodeJS and check what output is produced with some input and build test suite manually based on that. But in the other hand, whatever takes things forward and makes it possible for the community to contribute is great too.... |
Format a date to a specific format and timezone.
Code:
var d = new Date().toLocaleDateString('zh-Hans-CN', {timeZone: 'America/Denver', hour12: false });
Results:
JS: d= 2018/11/26
Jint: d= Monday, November 26, 2018
The text was updated successfully, but these errors were encountered: