Skip to content

Instantly share code, notes, and snippets.

@yovchev
Last active October 21, 2022 20:21
Show Gist options
  • Save yovchev/e25f2fee83d19752506ed655d3495423 to your computer and use it in GitHub Desktop.
Save yovchev/e25f2fee83d19752506ed655d3495423 to your computer and use it in GitHub Desktop.
Birthday Gifts
{% assign dob = '1990-05-31 00:00' %}
{% assign claimed = '2022-06-01 18:48' %}
{% assign nowYear = 'now' | date: '%Y' %}
{% assign nowEpoch = 'now' | date: '%s' %}
{% assign nowTimestamp = 'now' | date: "%Y-%m-%d %H:%M" %} <!-- optional -->
{% assign claimedEpoch = claimed | date: '%s' %}
{% assign claimedTimestamp = claimed| date: "%Y-%m-%d %H:%M" %} <!-- optional -->
{% assign birthYear = dob | date: '%Y' %}
{% assign birthEpoch = dob | date: '%s' %}
{% assign birthTimestamp = dob| date: "%Y-%m-%d %H:%M" %} <!-- optional -->
{% assign birthDateEpoch = dob | replace: birthYear, nowYear | date: '%s' %}
{% assign birthDateTimestamp = birthDateEpoch | date: "%Y-%m-%d %H:%M" %}
{% assign since_claimed = nowEpoch | minus: claimedEpoch | divided_by: 3600 | divided_by: 24 %}
{% assign since_birthDate = nowEpoch | minus: birthDateEpoch | divided_by: 3600 | divided_by: 24 %}
<pre>
dob: {{ dob }}
claimed: {{ claimed }}
-----------------------------------------------------------------------
now: {{ nowYear }} / {{ nowEpoch }} / {{ nowTimestamp }}
birth: {{ birthYear }} / {{ birthEpoch }} / {{ birthTimestamp }}
claimed: {{ claimedEpoch }} / {{ claimedTimestamp }}
-----------------------------------------------------------------------
birthDate: replace {{ birthYear }} with {{ nowYear }} = {{ birthDateEpoch }} / birthday this year is on {{ birthDateTimestamp }}
-----------------------------------------------------------------------
since_claimed: {{ since_claimed }} Days
since_birthDate: {{ since_birthDate }} Days
</pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment