Adding two helpers to make it easier to compare dates #107
+165
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FUNCTIONS
DESCRIPTION (WHAT)
The Stencil framework returns date strings using a PHP format of "M jS Y" in the
page context. This function converts the string to milliseconds since Jan 1, 1970in order to make it easier to perform date comparisons and operations.
USE CASE (WHY)
Some examples of how this would be used include the following story: As a merchant,
I want to display a carousel on my category pages that displays cards for products
that were added to the catalog within the last month. In order to do that, I need
to be able to convert the "date added" field that appears in the product cards under
the category.products object. Likewise, the same behavior would apply to brand pages
with products.
USAGE
{{#if (phpDateToTimestamp 'category.products[0].date_added.') >
((getTime) - theme_settings.new_product_lag)) }}
/* product is newer than the given time interval */
{{/if}}
and similarly with brands: 'brands.products[0].date_added.')
@mcampa