Skip to content
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

Feature/date format #76

Closed
wants to merge 6 commits into from
Closed

Conversation

KurtMar
Copy link
Contributor

@KurtMar KurtMar commented Sep 19, 2020

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.

@madisvain
Copy link
Owner

@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

@KurtMar
Copy link
Contributor Author

KurtMar commented Sep 26, 2020

@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
Copy link
Contributor Author

KurtMar commented Sep 26, 2020

@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.

@madisvain
Copy link
Owner

PR no longer relevant after rewrite to Tauri

@madisvain madisvain closed this Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Date format (localization)
2 participants