harttle / liquidjs

A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
https://liquidjs.com
MIT License
1.52k stars 238 forks source link

Support dates in unix timestamp format #512

Closed greatwitenorth closed 2 years ago

greatwitenorth commented 2 years ago

When I use a unix timestamp below as the creation_date I get weird unexpected values for the date.

{{creation_date | date: "%b %e, %Y"}}

Unix timestamps are of int type while the date filter expects a string. When a unix timestamp is converted to a string, then used in new Date(stringUnixTimestamp) it creates an invalid date. If would be nice if the library could detect if the incoming value is a string or int and keep their types accordingly.

harttle commented 2 years ago

Can you provide a template to reproduce the problem? unix timestamps are expected to be supported. Here's a demo: https://liquidjs.com/playground.html#e3sgMTY1Njc2NjM2MCB8IGRhdGU6ICclWS8lbS8lZCcgfX0=,e30=