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