Shopify / Shopify/liquid

`<value> | date` filter to return a Date object from `Date.parse(<value>)`

Open
#955 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

This issue arises from jekyll/jekyll#6581

The intent is to be able to craft arbitrary dates and to enact date comparisons, like post.date in Jekyll for example.

For example, crafting a date and fetching a post published on that day:

{% assign day = '01' | prefix: '2017-12-' | date %}
{% assign post = site.posts | where_exp: 'post', 'post.date == day' | first %}

At the moment, the only known ways to create a plain Date object is with 'now' | date and 'today' | date.

Current code is:

https://github.com/Shopify/liquid/blob/85b1e91aed47bcfebfb4d349d8500fb9737d7873/lib/liquid/standardfilters.rb#L277-L283

What do you think?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the date-filter implementation in lib/liquid/standardfilters.rb at the linked lines, then compare its current handling of 'now' and 'today' with the proposed crafted-date example. Done should provide a clear way for a parsed date value to become a Date object and compare with post.date, while preserving existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.