Sha256: 19eccc0d17016dea40ac56161de1a987b8b5aa414a9598274edbcfc98be4003b
Contents?: true
Size: 744 Bytes
Versions: 1
Compression:
Stored size: 744 Bytes
Contents
# frozen_string_literal: true class Date # http://stackoverflow.com/questions/819263/get-persons-age-in-ruby #------------------------------------------------------------------------------ def to_age now = Time.now.utc.to_date now.year - year - (now.month > month || (now.month == month && now.day >= day) ? 0 : 1) end #------------------------------------------------------------------------------ def localize(options = {}) options = { format: options } if options.instance_of?(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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dm_ruby_extensions-1.5.0 | lib/dm_ruby_extensions/extend_date.rb |