Recent Posts (Page 1)

Photo by Mick Hauptvia Unsplash
Photo by Mick Haupt via Unsplash

Golangs $date.Format is unable to add ordinal suffixes to dates (like 1st, 2nd, 3rd, 4th). Let’s not judge Golang for that. The following is how I remedy this issue: layouts/partials/func/formatOrdinalDate.html 1{{-$format:=.format-}} 2{{-$date:=.date-}} 3{{-$shortened:="th"-}} 4{{-ifin(slice12131)$date.Day-}} 5{{-$shortened="st"-}} 6{{-elseifin(slice222)$date.Day-}} 7{{-$shortened="and"-}} 8{{-elseifin(slice323)$date.Day-}} 9{{-$shortened="rd"-}} 10{{-end}} 11{{-return$date.