Class: DateTime
- Inherits:
-
Object
- Object
- DateTime
- Defined in:
- lib/dm_ruby_extensions/extend_datetime.rb
Overview
Instance Method Summary collapse
-
#localize(options = {}) ⇒ Object
——————————————————————————.
-
#to_age ⇒ Object
——————————————————————————.
-
#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_datetime.rb', line 11 def localize( = {}) = { format: } if .instance_of?(String) I18n.localize(self, **) end |
#to_age ⇒ Object
6 7 8 |
# File 'lib/dm_ruby_extensions/extend_datetime.rb', line 6 def to_age (DateTime.now - self).to_i / 365 end |
#to_index ⇒ Object
Create a unique sortable index for this date
18 19 20 |
# File 'lib/dm_ruby_extensions/extend_datetime.rb', line 18 def to_index yday + (year - 2000) * 1000 end |