Last active
December 13, 2015 20:08
-
-
Save aprescott/4967417 to your computer and use it in GitHub Desktop.
Ordinals in straight Liquid templates.
This file contains 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
{% assign d = time | date: "%d" | plus:0 %} | |
{% assign d_mod = d | modulo:10 %} | |
{% assign ordinals = "th,st,nd,rd,th,th,th,th,th,th" | split:"," %} | |
{% if d > 10 and d < 14 %} | |
{{ d }}th | |
{% else %} | |
{{ ordinals[d_mod] }} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment