aboutsummaryrefslogtreecommitdiff
path: root/plugins/date.rb
diff options
context:
space:
mode:
authorFrederic Hemberger <mail@frederic-hemberger.de>2011-11-04 08:11:16 +0100
committerFrederic Hemberger <mail@frederic-hemberger.de>2011-11-04 08:11:16 +0100
commit142681489f1a2aad7bc9f225ec7d7a0c1c476e09 (patch)
tree3c59ac82a0644745c9729cd87cbd355e817fd49c /plugins/date.rb
parent987dccee7655a410a2fb1e0f41c35b282b17cbe9 (diff)
downloadmy_new_personal_website-142681489f1a2aad7bc9f225ec7d7a0c1c476e09.tar.xz
my_new_personal_website-142681489f1a2aad7bc9f225ec7d7a0c1c476e09.zip
Add custom date format %o for ordinal representation of the day
Diffstat (limited to '')
-rw-r--r--plugins/date.rb4
1 files changed, 4 insertions, 0 deletions
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