Skip to content

parse_date does not work as described in the documentation #1410

Description

@greyskin

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 }}.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions