Open hemanth307 opened 4 months ago
You can use DateTime.parseFormatForOpts
to convert any formatting options (like DATE_MED_WITH_WEEKDAY
) into a format string:
console.log(DateTime.parseFormatForOpts(DateTime.DATE_MED_WITH_WEEKDAY)); // outputs: EEE, MMM d, yyyyy
expandMacroTokens
is available via DateTime.expandFormat
:
console.log(DateTime.expandFormat('DDD')); // outputs: MMMM d, yyyyy
Let me know if this solves your use cases.
Thank You That Helped, but i also have a locale which might be changing the format so can i pass the locale with the macrotoken format and get the particular format.
Is there a way i can get the format if i pass the JavaScript Date Object and the locale. I need format not the formatted value.
Can we get a macro option for DATE_MED_WITH_WEEKDAY which can change with the locale provided like for other tokens.
parseFormatForOpts
and expandFormat
accept a 2nd parameter "localeOpts", which lets you configure the locale. Specifically this accepts an object with keys locale
(like "en-US"), numberingSystem
, outputCalendar
and weekSettings
.parseFormatForOpts
should solve this for you by letting you expand DATE_MED_WITH_WEEKDAY
manually.
I am currently using macro tokens for date formats, and I need to expand them for placeholders. However, I have encountered two issues:
(i) The expandMacroTokens functions are not exported, which makes it challenging to use them for custom formatting.
(ii) Not all Luxon formats have corresponding macro tokens (e.g., DATE_MED_WITH_WEEKDAY).
It would be extremely helpful if macro tokens could be added for every format, and if the expandMacroTokens functions could be exported for easier customization.
Thank you for considering this feature request.