Skip to content

Instantly share code, notes, and snippets.

@steverydz
Created July 2, 2013 20:24
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 steverydz/5912778 to your computer and use it in GitHub Desktop.
Save steverydz/5912778 to your computer and use it in GitHub Desktop.
This is a plugin for Jekyll that adds ordinals to dates.
require 'date'
require 'facets/integer/ordinal'
module Jekyll
module DateFilter
def prettydate(date)
"#{date.strftime('%e').to_i.ordinalize} #{date.strftime('%B')} #{date.strftime('%Y')}"
end
end
end
Liquid::Template.register_filter(Jekyll::DateFilter)
@steverydz
Copy link
Author

To use this the facets gem needs to be installed gem install facets. This file must be saved in the _plugins directory. Then used like so: {{ post.date | prettydate }} Note: This does not work for sites hosted on Github pages as plugins aren't supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment