Module: DataMagic::DateTranslation
- Included in:
- DataMagic, Translation
- Defined in:
- lib/data_magic/date_translation.rb
Instance Method Summary collapse
-
#day_of_week ⇒ Object
(also: #dm_day_of_week)
return a day of the week.
- #day_of_week_abbr ⇒ Object (also: #dm_day_of_week_abbr)
-
#month ⇒ Object
(also: #dm_month)
return a month.
-
#month_abbr ⇒ Object
(also: #dm_month_abbr)
return a month abbreviation.
-
#today(format = '%D') ⇒ Object
(also: #dm_today)
return today’s date.
-
#tomorrow(format = '%D') ⇒ Object
(also: #dm_tomorrow)
return tomorrow’s date.
-
#yesterday(format = '%D') ⇒ Object
(also: #dm_yesterday)
return yesterday’s date.
Instance Method Details
#day_of_week ⇒ Object 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_abbr ⇒ Object 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 |
#month ⇒ Object 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_abbr ⇒ Object 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
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
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
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 |