Skip to content

Instantly share code, notes, and snippets.

@maiha
Created February 27, 2009 22:13
Show Gist options
  • Save maiha/71733 to your computer and use it in GitHub Desktop.
Save maiha/71733 to your computer and use it in GitHub Desktop.
"_03_".to_i
# => 3 # ruby 1.8
# => 0 # ruby 1.9
--- a/merb-helpers/lib/merb-helpers/date_time_formatting.rb
+++ b/merb-helpers/lib/merb-helpers/date_time_formatting.rb
@@ -151,6 +151,6 @@ module OrdinalizedFormatting
# ==== Examples
# 5.days.ago.strftime_ordinalized('%b %d, %Y') # =>
def strftime_ordinalized(fmt, format=nil)
- strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
+ strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { $1.to_i.ordinalize }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment