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

date filter should return parsed input when no format is provided #573

Open
sebastienros opened this issue Dec 20, 2022 · 2 comments
Open

Comments

@sebastienros
Copy link

Expected:

image

Actual:
https://liquidjs.com/playground.html#e3sgJ25vdycgfCBkYXRlIH19Cnt7ICcyMDIyLTEyLTA3VDIyOjIyOjE4JyB8IGRhdGUgfX0K,e30=

@harttle
Copy link
Owner

harttle commented Dec 22, 2022

Actually in my local shopify/liquid, it yields an error:

liquid/lib/liquid/standardfilters.rb:681:in `date': wrong number of arguments (given 1, expected 2) (ArgumentError)

But I do think it's better to output something instead of throwing. Now what I can find in JavaScript (with most similarity) is Date.toString(), what do you think?

> (new Date()).toString()
Thu Dec 22 2022 22:40:58 GMT+0800 (Taipei Standard Time)'

github-actions bot pushed a commit that referenced this issue Jan 2, 2023
# [10.4.0](v10.3.3...v10.4.0) (2023-01-02)

### Features

* support `not` operator, [#575](#575) ([3f21382](3f21382))
* support calling `date` without format string, [#573](#573) ([aafaa0b](aafaa0b))
@harttle
Copy link
Owner

harttle commented Jan 2, 2023

Date.toString()

I find this approach is not feasible for TimezoneDate. Now I'm trying to set the default format string to '%A, %B %-e, %Y at %-l:%M %P %z' when it's not provided, so that the use case you provided can pass the test.

It seems OK in this test case:

it('should support timezone without format', function () {
return test('{{ "2022-12-08T03:22:18.000Z" | date: nil, "America/Cayman" }}', 'Wednesday, December 7, 2022 at 10:22 pm -0500')
})

The timezone is specified so that this test case can be env independant, more realistic use case is:

it('should support "now"', function () {
return test('{{ "now" | date }}', /\w+, January \d+, 2023 at \d+:\d\d [ap]m [-+]\d\d\d\d/)
})

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

No branches or pull requests

2 participants