From 142681489f1a2aad7bc9f225ec7d7a0c1c476e09 Mon Sep 17 00:00:00 2001 From: Frederic Hemberger Date: Fri, 4 Nov 2011 08:11:16 +0100 Subject: Add custom date format %o for ordinal representation of the day --- plugins/date.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins') diff --git a/plugins/date.rb b/plugins/date.rb index c1c69551..8758f23f 100644 --- a/plugins/date.rb +++ b/plugins/date.rb @@ -29,12 +29,16 @@ module Octopress end end + # Formats date either as ordinal or by given date format + # Adds %o as ordinal representation of the day def format_date(date, format) date = datetime(date) if format.nil? || format.empty? || format == "ordinal" date_formatted = ordinalize(date) else + format.gsub!(/%o/, '%%o') date_formatted = date.strftime(format) + date_formatted.gsub!(/%o/, ordinal(date.strftime('%e').to_i)) end date_formatted end -- cgit v1.2.1