You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, you're right. We can customize locale date/time string in JavaScript, but not as flexible as in strftime.
Intl.DateTimeFormat and .toLocaleDateString() both support a format options parameter which contains something like dateStyle, timeStyle, year, month. While I can't find a way to implement strftime with it.
@harttle would an option for global/default date format help, similar to timezoneOffset?
In current code, the default format is hard coded.
With such an option, engine users will be free to set whatever format they need, however they got it (Intl, user configured, ...).
I use the similar timezoneOffset option, to get all dates in the templates converted to the required tz.
Of course, this is for the developers who setup/init the Liquid engine, and not for the template designers.
Activity
harttle commentedon Dec 11, 2022
We have problem in JavaScript that
Datedoesn't support format string. We'll need localizations for this purpose, I'm thinking that we can create a separate project to port a strftime lib to Liquiddatefilter. like this one: https://github.com/samsonjs/strftime#localespdehaan commentedon Dec 11, 2022
JavaScript does have an
Intl.DateTimeFormat, which "enables language-sensitive date and time formatting."flaviotordini commentedon Dec 11, 2022
In the meantime I used this:
The downside is that it does not support string patterns.
harttle commentedon Dec 12, 2022
Yes, you're right. We can customize locale date/time string in JavaScript, but not as flexible as in strftime.
Intl.DateTimeFormatand.toLocaleDateString()both support a format options parameter which contains something likedateStyle,timeStyle,year,month. While I can't find a way to implement strftime with it.prassie commentedon Feb 2, 2023
@harttle would an option for global/default date format help, similar to timezoneOffset?
In current code, the default format is hard coded.
With such an option, engine users will be free to set whatever format they need, however they got it (Intl, user configured, ...).
I use the similar timezoneOffset option, to get all dates in the templates converted to the required tz.
Of course, this is for the developers who setup/init the Liquid engine, and not for the template designers.
harttle commentedon Feb 4, 2023
Makes sense. Thank you @prassie for the clarification.
feat: date filter support locale, #567
feat: locale support for date filter, #567
feat: locale support for date filter, #567
feat: locale support for date filter, #567 (#723)
chore(release): 10.16.0 [skip ci]
harttle commentedon Jul 21, 2024
weekday and months are now locale specific, details please check: https://liquidjs.com/filters/date.html