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
By default, the liquid template outputs UTC format, but we want to give the Template builder the ability to conveniently convert the time to the same time specified in the system configuration settings.
public static ValueTask<FluidValue> LocalDateFilter(FluidValue input, FilterArguments arguments, TemplateContext context)
{
var value = TimeZoneConverter(input, context);
return ReferenceEquals(value, NilValue.Instance) ? value : MiscFilters.Date(value, arguments, context);
}
private static FluidValue TimeZoneConverter(FluidValue input, TemplateContext context)
{
if (!input.TryGetDateTimeInput(context, out var value))
{
return NilValue.Instance;
}
var utc = DateTime.SpecifyKind(value.DateTime, DateTimeKind.Utc);
// Create new offset for UTC
var localOffset = new DateTimeOffset(utc, TimeSpan.Zero);
var result = TimeZoneInfo.ConvertTime(localOffset, context.TimeZone);
return new DateTimeValue(result);
}
By default, the liquid template outputs UTC format, but we want to give the Template builder the ability to conveniently convert the time to the same time specified in the system configuration settings.
Example:
<span class="ud-blog-date">{{ item.CreationTime | organization_time: '%b %e %Y, %l:%M:%S %P' }}</span>
The following code needs to be added to https://github.com/RaythaHQ/raytha/blob/main/src/Raytha.Web/Services/RenderEngine.cs
And:
options.Filters.AddFilter("organization_time", LocalDateFilter);
And we should update the default template too so this filter is in use for fresh installations.
The text was updated successfully, but these errors were encountered: