Sha256: 39b8fba64661a0d6606d7ea30fdb12fe2fcb94d4d29b45eb24c0cff101fbd0df

Contents?: true

Size: 644 Bytes

Versions: 6

Compression:

Stored size: 644 Bytes

Contents

#------------------------------------------------------------------------------
class DateTime

  #------------------------------------------------------------------------------
  def to_age
    (DateTime.now - self).to_i / 365
  end

  #------------------------------------------------------------------------------
  def localize(options = {})
    options = {:format => options} if options.class == String      
    I18n.localize(self, options)
  end
  
  # Create a unique sortable index for this date
  #------------------------------------------------------------------------------
  def to_index
    yday + (year-2000) * 1000
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dm_ruby_extensions-1.0.9 lib/dm_ruby_extensions/extend_datetime.rb
dm_ruby_extensions-1.0.8 lib/dm_ruby_extensions/extend_datetime.rb
dm_ruby_extensions-1.0.7 lib/dm_ruby_extensions/extend_datetime.rb
dm_ruby_extensions-1.0.6 lib/dm_ruby_extensions/extend_datetime.rb
dm_ruby_extensions-1.0.5 lib/dm_ruby_extensions/extend_datetime.rb
dm_ruby_extensions-1.0.0 lib/dm_ruby_extensions/extend_datetime.rb