upcount icon indicating copy to clipboard operation
upcount copied to clipboard

Feature/date format

Open KurtMar opened this issue 4 years ago • 3 comments

Closes #71

Affects invoice form, invoice and date picker. If there is a better way of getting the organization's settings to the utility functions, then it would simplify things a bit. NOTE: New translation string in invoice settings.

KurtMar avatar Sep 19 '20 14:09 KurtMar

@KurtMar thank you for this pull request. This is great work. I would only add some kind of custom format validator but another option is to have the users specify a locale not a specific format.

https://momentjs.com/docs/#/i18n/changing-locale/

So we could globally load this locale and all the dates / etc will be rendered accordingly. We would end up with a little less code hopefully.

Then we could also use the localisation of Antd like shown here in the docs: https://ant.design/components/date-picker/#Localization

Moment has a long list of locales available so I would not be worried that something is not available: https://github.com/moment/moment/tree/develop/locale

madisvain avatar Sep 26 '20 07:09 madisvain

@madisvain Thanks for the input. Setting the locale from a list sounds like a good idea.

Do you want to get rid of the formatting functions all together and call moment directly from inside the view components or is it ok to keep using them? I have time to refactor to using moment locales, but for the date picker I would still use moment to format the date for now.

Also since the default locale for moment will give us a format of MM/DD/YYYY, if we still want to use the default YYYY-MM-DD for undefined locale, that would require some logic and those functions would hold that.

KurtMar avatar Sep 26 '20 12:09 KurtMar

@madisvain I went along and changed it to use locales. There's also a custom default locale that will ensure that the current default date formatting is kept. Feel free to make further suggestions or modifications if needed. Especially where to set the user's custom moment locale is something I struggled with. It is currently set when the user opens the Invoices page.

I'm not a huge fan of the mutable and global nature of moment, but this seems to be a working solution.

KurtMar avatar Sep 26 '20 17:09 KurtMar