liquid-rust icon indicating copy to clipboard operation
liquid-rust copied to clipboard

“now” date is UTC, not local

Open ticky opened this issue 6 years ago • 3 comments
trafficstars

The “now” keyword, when passed to the date filter in Shopify Liquid calls out to Ruby's Time.now, which returns the current time, in the current system time zone:

$ irb
irb(main):001:0> Time.now
=> 2019-02-08 15:34:25 -0800

liquid-rust’s implementation uses the current time in UTC, which makes templates relying on the upstream Liquid behaviour behave incorrectly!

For instance, my site uses {{ 'now' | date: "%b %-d, %I:%M %P %Z" }} to print the compilation time in the footer of pages, and it is my intent that this shows in the local time zone of the machine that generated it, however, this now emits the date in UTC, which is less desirable to me.


liquid-rust version: master rust version: 1.32.0 OS: macOS 10.14

ticky avatar Feb 08 '19 23:02 ticky

It does? Thats disappointing. If you use a CI to build your site, it is unpredictable what time zone it will be in.

Oh, well. The joy of compatibility.

epage avatar Feb 09 '19 00:02 epage

It’s definitely not a great stance, and I think the suggested workaround is to adjust the time zone of the application (i.e. you could do this by setting TZ, or as Jekyll does, by adjusting it at the build config level), but given that Liquid makes no attempt to allow you to select a time zone for display otherwise, it’d be good to keep it consistent :)

ticky avatar Feb 11 '19 17:02 ticky

Agreed though I think it might be nice to offer a feature flag to change from local to UTC.

epage avatar Feb 11 '19 17:02 epage