J2V8 icon indicating copy to clipboard operation
J2V8 copied to clipboard

Date.toLocaleString doesn't support locales and options params

Open ilyamuromets opened this issue 5 years ago • 4 comments

Nodejs doesn't support locales and options params in the next functions of Date's object: toLocaleString, toLocaleDateString, toLocaleTimeString? I have the snippet to check support:

(function() {
  try {
    new Date().toLocaleTimeString('i');
  } catch (e) {
    return e.name === 'RangeError';
  }
  return false;
})();

This code returns true in browsers and false in j2v8.

Seems as Nodejs supports functions without these params. And is it possible to run v8 in your project with custom locale, not the en-US?

I found the next: https://github.com/nodejs/node/issues/8500#issuecomment-246432058

ilyamuromets avatar May 16 '19 08:05 ilyamuromets

I have found out that you build nodejs with flag --without-intl, maybe this is why locales and options params doesn't work.

ilyamuromets avatar May 16 '19 15:05 ilyamuromets

When we frist started, internationalization added hundreds of MB to the library so we disabled it. If someone would like to try and build with i18l enabled and report back about the impact, we could then make a plan.

irbull avatar May 22 '19 02:05 irbull

Thanks for reply! Yet one question: is it possible to build j2v8 and include (third party node module)? If yes, could you forward me to example how to do that?

ilyamuromets avatar May 31 '19 13:05 ilyamuromets

@irbull Making localization pluggable could be an option. Often times the underlying os is able to provide the current timezone offset.

mpost avatar Jun 05 '19 13:06 mpost