-
Notifications
You must be signed in to change notification settings - Fork 79
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
Support more date formats in the date
filter
#48
Comments
That would also be a good opportunity to add support for the magic |
If the liquid syntax allows this, I think it'd be nice to read This would be a bit non-conformant but would be a great for testing. |
That would be interesting, but I'm not sure how to make that work within the filter. Conceptually, we'd need to have "today" and "now" be special terms that would be rendered external to the filter if they exist within the Context, and only be handled by the filter if they are not defined within the Context. Is that what you were thinking? |
date
filter
For cobalt-org/cobalt.rs#349, I looked up how shopify's
The remaining question is what should serde support do. Do we support a single format or accept any format? First, this assumes we add a My thought is that if we add a |
This is a small step to cobalt-org#48 for the purpose of supporting cobalt changing its format.
`date` but not `date_in_tz` was updated to parse more than one date format when cobalt switched formats. This updates `date_in_tz` to do so as well. This was done by centralizing the date parsing logic as discussed in cobalt-org#48.
Would a PR adding at least a few more ISO8601/RFC3339 date formats to the formats Liquid will try be accepted? I realise the ultimate goal is to accept anything Ruby’s |
As long as they are formats supported by the Ruby implementation, go for it. We don't have to tackle this all at once. |
I'm working with this now, and wanted some feedback on the formats I'm adding. The following formats are going into the
Those will be supported both with and without offsets. For those without offsets, the timezone will be set to the local offset (of the host on which the program is running). For those with offsets, only the forms Also, I'm adding in "today" and "Today" as synonyms for "now". To support local offsets, the feature "local-offset" must be enabled for the time dependency in the Any questions, comments, critiques are welcome. Hopefully I'll have something to throw into a PR within the next few days. |
Let's start with defaulting to +0000 instead of local time. Maybe I'm confusing this with cobalt but I think we already default to +0000 in other parts. There are also a lot of problems surrounding local offsets that they will be nearly impossible to use in a library (which is why its behind a feature flag). |
I don't think you're confusing it with cobalt - we do default to UTC everywhere for now. |
In https://github.com/cobalt-org/liquid-rust/blob/master/src/filters.rs#L308 we use a custom date format to parse dates for the date filter if it's a string.
The original liquid has a
to_date
function that can take different types of input and parse it. We might even parse different date formats that way https://github.com/Shopify/liquid/blob/master/lib/liquid/utils.rb#L63The text was updated successfully, but these errors were encountered: