Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/dm_ruby_extensions/extend_date.rb
Instance Method Summary collapse
-
#localize(options = {}) ⇒ Object
——————————————————————————.
-
#to_age ⇒ Object
stackoverflow.com/questions/819263/get-persons-age-in-ruby ——————————————————————————.
-
#to_index ⇒ Object
Create a unique sortable index for this date ——————————————————————————.
Instance Method Details
#localize(options = {}) ⇒ Object
11 12 13 14 |
# File 'lib/dm_ruby_extensions/extend_date.rb', line 11 def localize( = {}) = {:format => } if .class == String I18n.localize(self, ) end |
#to_age ⇒ Object
5 6 7 8 |
# File 'lib/dm_ruby_extensions/extend_date.rb', line 5 def to_age now = Time.now.utc.to_date now.year - self.year - ((now.month > self.month || (now.month == self.month && now.day >= self.day)) ? 0 : 1) end |
#to_index ⇒ Object
Create a unique sortable index for this date
18 19 20 |
# File 'lib/dm_ruby_extensions/extend_date.rb', line 18 def to_index yday + (year-2000) * 1000 end |