Get the format used by a preset for a given culture? #1126
-
I couldn't find this in the docs and it's quite hard to search for. Is there a way to get the actual format of a given preset in a given culture? For example, for "DATE_SHORT" in "en-US", I want the value "MM/dd/yyyy". For "DATE_SHORT" in "en-GB", it should be "dd/MM/yyyy". I need to feed this string to an input masker so it helps the user type the date in correctly. Short of that, is there at least some way to know the order of the parts? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It seems like maybe this isn't possible generically in JS, so it wouldn't be in Luxon, either? Ended up using something like this: https://stackoverflow.com/a/66858753/11991371 |
Beta Was this translation helpful? Give feedback.
-
So, the answer is no, but Luxon could do it because we have code very similar to that SO answer, used for slightly different purposes. Just needs rearranged (see Also requested here #839 |
Beta Was this translation helpful? Give feedback.
So, the answer is no, but Luxon could do it because we have code very similar to that SO answer, used for slightly different purposes. Just needs rearranged (see
maybeExpandMacroToken
in tokenParser.js). If someone made a small PR to do that, I'd likely take it. In the meantime, that SO link is roughly what I'd recommend too.Also requested here #839