Adding two helpers to make it easier to compare dates#107
Open
elephantengine wants to merge 3 commits intobigcommerce:masterfrom
Open
Adding two helpers to make it easier to compare dates#107elephantengine wants to merge 3 commits intobigcommerce:masterfrom
elephantengine wants to merge 3 commits intobigcommerce:masterfrom
Conversation
Contributor
|
Thanks for your contribution. However, I'm not 100% sure how this would work. As far as I know, the formatted dates Instead of doing the conversion in the template layer, maybe we should provide unformatted timestamps in Stencil resources? @mcampa what are your thoughts? |
Contributor
Author
|
In the developer documentation for the BigCommerce API, it mentions that all dates are returned in GMT - wouldn't that also be the case in terms of Stencil? |
Contributor
|
I agree with @davidchin, we should provide the timestamp. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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