Module: DataMagic::DateTranslation

Included in:
DataMagic, Translation
Defined in:
lib/data_magic/date_translation.rb

Instance Method Summary collapse

Instance Method Details

#day_of_weekObject Also known as: dm_day_of_week

return a day of the week



63
64
65
# File 'lib/data_magic/date_translation.rb', line 63

def day_of_week
  randomize(Date::DAYNAMES)
end

#day_of_week_abbrObject Also known as: dm_day_of_week_abbr



68
69
70
# File 'lib/data_magic/date_translation.rb', line 68

def day_of_week_abbr
  randomize(Date::ABBR_DAYNAMES)
end

#monthObject Also known as: dm_month

return a month



47
48
49
# File 'lib/data_magic/date_translation.rb', line 47

def month
  randomize(Date::MONTHNAMES[1..-1])
end

#month_abbrObject Also known as: dm_month_abbr

return a month abbreviation



55
56
57
# File 'lib/data_magic/date_translation.rb', line 55

def month_abbr
  randomize(Date::ABBR_MONTHNAMES[1..-1])
end

#today(format = '%D') ⇒ Object Also known as: dm_today

return today’s date

See ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-i-strftime for details of the formats

Parameters:

  • String

    the format to use for the date. Default is %D



11
12
13
# File 'lib/data_magic/date_translation.rb', line 11

def today(format = '%D')
  Date.today.strftime(format)
end

#tomorrow(format = '%D') ⇒ Object Also known as: dm_tomorrow

return tomorrow’s date

See ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-i-strftime for details of the formats

Parameters:

  • String

    the format to use for the date. Default is %D



24
25
26
27
# File 'lib/data_magic/date_translation.rb', line 24

def tomorrow(format = '%D')
  tomorrow = Date.today + 1
  tomorrow.strftime(format)
end

#yesterday(format = '%D') ⇒ Object Also known as: dm_yesterday

return yesterday’s date

See ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-i-strftime for details of the formats

Parameters:

  • String

    the format to use for the date. Default is %D



38
39
40
41
# File 'lib/data_magic/date_translation.rb', line 38

def yesterday(format = '%D')
  yesterday = Date.today - 1
  yesterday.strftime(format)
end