Module: ApplicationHelper

Defined in:
lib/myrails/templates/rails/app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#long_date(date) ⇒ Object

Long date format

Parameters:

  • date (Date)

    the date object

Returns:

  • day date month year - hour:minutes AM/PM



6
7
8
# File 'lib/myrails/templates/rails/app/helpers/application_helper.rb', line 6

def long_date(date)
  date.strftime("%A %d %B %Y - %H:%M %p") rescue 'unknown'
end

#medium_date(date) ⇒ Object

Medium date format

Parameters:

  • date (Date)

    the date object

Returns:

  • month/date/year at hour:minutes AM/PM



14
15
16
# File 'lib/myrails/templates/rails/app/helpers/application_helper.rb', line 14

def medium_date(date)
  date.strftime("%m/%d/%Y at %H:%M %p") rescue 'unknown'
end

#medium_date2(date) ⇒ Object

Another style of medium date format

Produces -> 18 October 2015

Parameters:

  • date (Date)

    the date object

Returns:

  • day/MONTH/YEAR



23
24
25
# File 'lib/myrails/templates/rails/app/helpers/application_helper.rb', line 23

def medium_date2(date)
  date.strftime("%d %B %Y") rescue 'unknown'
end

#short_date(date) ⇒ Object

Short date format

Parameters:

  • date (Date)

    the date object

Returns:

  • year-month-date



31
32
33
# File 'lib/myrails/templates/rails/app/helpers/application_helper.rb', line 31

def short_date(date)
  date.strftime("%Y-%m-%d") rescue 'unknown'
end

#us_date(date) ⇒ Object

US date format

Parameters:

  • date (Date)

    the date object

Returns:

  • year-month-date



39
40
41
# File 'lib/myrails/templates/rails/app/helpers/application_helper.rb', line 39

def us_date(date)
  date.strftime("%m/%d/%Y at %H:%M %p") rescue 'unknown'
end