Skip to content
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

parse_date does not work as described in the documentation #1410

Open
greyskin opened this issue Aug 29, 2023 · 0 comments
Open

parse_date does not work as described in the documentation #1410

greyskin opened this issue Aug 29, 2023 · 0 comments

Comments

@greyskin
Copy link

The title says it all. I'm reluctant to suggest updates to the documention until I get some feedback about the intended use of this filter.

Documentation: https://doc.locomotivecms.com/docs/filters#parse_date

Copy and paste directly from the documentation example:
{{ '2015-09-26' | parse_date }}
Result: Renders nothing in wagon and engine

It's unclear from the documentation how the format option is supposed to be used. Based on the money filter options, I tried:
{{ '2015-09-26' | parse_date: format: '%m/%d/%Y' }}
Result: error message - "no implicit conversion of Hash into String" (wagon and engine)


I found this GitHub issue where parse_date is mentioned and the example given is:
{% assign date_a = "2015-11-01" | parse_date: '%Y-%m-%d' %}

This appears to be more acurate than the documentation.
The following snippet works in both wagon and engine:

{% assign myDate = '08-28-2023' | parse_date: '%m-%d-%Y' %}
{% if now > myDate %}
    today comes after myDate
{% else %}
    today comes before myDate
{% endif %}

Note the American date format mm-dd-yyyy. This is how I know that the parse_date filter is working here. If I run the same snippet without the parse_date filter, I get an error message - "comparison of ActiveSupport::TimeWithZone with String failed".

It seems to me that parse_date is intended for use in Liquid tags, not objects, i.e. with {% and %} delimiters, not {{ and }}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant