Premium support for our pure JavaScript UI components


Post by takafumi ohtake »

Hi,

I'm trying to localize the date formats of a Gantt chart following https://www.bryntum.com/docs/gantt/guide/Gantt/customization/localization#change-date-formats.
But when I change the locale, the Gantt chart become not able to parse localized date fields.

image.png
image.png (24.01 KiB) Viewed 536 times

My code is,

  const loc = LocaleHelper.mergeLocales(EnglishLocale, {
    DateHelper: {
      locale: 'ja-JP',
    },
  });

  LocaleManager.registerLocale('Ja', { desc: 'Japanese', locale: loc });
  LocaleManager.applyLocale('Ja');

Does DateHelper support parse localized dates?
How can I localize date formats?


Post by alex.l »

Hi takafumi ohtake,

Visible dates and data that loaded as a value are not the same. Your data still should follow JS standards.
Could you please show the value that you used for that field?

I just applied minimal changes to De localization file in our localization example of Gantt (you can find it in your sources in examples/localization/locales/custom.locale.De.js), I just changed DateHelper.locale to 'ja-JP' as in your example above and it works great. Please try yourself.

Attachments
Screenshot 2021-12-15 at 17.01.55.png
Screenshot 2021-12-15 at 17.01.55.png (197.42 KiB) Viewed 534 times

All the best,
Alex


Post by takafumi ohtake »

Hi alex,

Thank you for your reply.
I've tried with the example source. But, I can't parse dates.
And, it happens in the De locale. It can be reproduced on your demo site.
https://bryntum.com/examples/gantt/localization/

cant_parse_date.mp4
(885.55 KiB) Downloaded 63 times

I think localized dates can be parsed only when "new Date(datestring)" can parse the string.

Could you try it?


Post by alex.l »

Yes, confirmed. Btw, it worked for "Feb" dates. The link to track the status is here: https://github.com/bryntum/support/issues/3901

Thanks a lot for the report!

All the best,
Alex


Post by takafumi ohtake »

Hi alex,

Thank you for your reply and for creating the issue.

I found DateHelper can parse localized dates if formatted with "L" format.
So, I realized I could avoid the problem by setting the format property with "L" to Gantt date's columns such as start and deadline.


Post by alex.l »

Great to hear it doesn't block you a lot! Thanks for finding!

All the best,
Alex


Post Reply