module OrdinalizedFormatting
Time.now.to_ordinalized_s :long
> “February 28th, 2006 21:10”¶ ↑
Public Instance Methods
strftime_ordinalized(fmt, format=nil)
click to toggle source
Gives you a relative date in an attractive format
Parameters¶ ↑
- format<String>
-
strftime string used to format a time/date object
- locale<String, Symbol>
-
An optional value which can be used by localization plugins
Returns¶ ↑
- String
-
Ordinalized time/date object
Examples¶ ↑
5.days.ago.strftime_ordinalized('%b %d, %Y') # =>
# File lib/merb-helpers/date_time_formatting.rb, line 153 def strftime_ordinalized(fmt, format=nil) strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { $1.to_i.ordinalize } end
to_ordinalized_s(format = :default)
click to toggle source
# File lib/merb-helpers/date_time_formatting.rb, line 136 def to_ordinalized_s(format = :default) format = Date.formats[format] return self.to_s if format.nil? strftime_ordinalized(format) end