Skip to content

Instantly share code, notes, and snippets.

@katyayu
Last active October 13, 2017 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katyayu/8f04e36da914559c6a32b094bd9ac7ba to your computer and use it in GitHub Desktop.
Save katyayu/8f04e36da914559c6a32b094bd9ac7ba to your computer and use it in GitHub Desktop.
{% if settings.badge_toggle and settings.new_products_period.size > 0 %}
{% comment %}Is this product new?{% endcomment %}
{% assign date_pub_y = product.published_at | date:'%Y' %}
{% assign date_pub_d = product.published_at | date:'%j' %}
{% assign date_now_y = 'now' | date:'%Y' %}
{% assign date_now_d = 'now' | date:'%j' %}
{% assign dates_diff_y = date_now_y | minus: date_pub_y | times: 365 %}
{% assign dates_diff_d = date_now_d | minus: date_pub_d %}
{% assign dates_diff = dates_diff_y | plus: dates_diff_d %}
{% assign new_products_period = settings.new_products_period | plus: 0 %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment