-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add a way to retrieve a UTC now datetime in Liquid #12339
Conversation
Why we didn't add UTC into Fluid? Or extend Now filter to support UTC through pipe operator
|
The first value there is what you are suggesting which doesn't work. |
And rename TimeZoneFilter to LocalTimeZoneFilter.
It is not just "now" but all DateTimes that are converted when passed in these filters. So, yes, adding a UTC one makes sense then. It will basically remove or add your tenant timezone offset to these DateTimes. |
src/OrchardCore.Modules/OrchardCore.Liquid/Filters/LocalTimeZoneFilter.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Liquid/Filters/UtcTimeZoneFilter.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Liquid/Filters/UtcTimeZoneFilter.cs
Outdated
Show resolved
Hide resolved
Relevant PR in Fluid to parse date time inputs (including There is a time_zone filter to convert to any timezone. ,e.g., |
utc: {{ "utc_now" | local | date: "%c" }}
local : {{ "now" | local | date: "%c" }}
local is the default : {{ "now" | date: "%c" }}
At the same time I'm questioning the TimeZoneFilter name now. "local" doesn't make sense anymore if we do this. The idea of the TimeZoneFilter should be to allow returning a local DateTime or a DateTime affected by an offset. Here, we should probably consider creating a filter that allows passing a TimeZoneId or an Offset value simply. Need to think about the design. But at the same time
| local
here doesn't make sense to be required to retrieve a UTC DateTime value.Else, a refactor of this filter might become a breaking change. Maybe better simply create a new one.