Module: Fortifier::DateHelper

Defined in:
app/helpers/fortifier/date_helper.rb

Instance Method Summary collapse

Instance Method Details

#american_date(date) ⇒ Object

Produces -> 5/21/2007



5
6
7
8
# File 'app/helpers/fortifier/date_helper.rb', line 5

def american_date(date)
  return nil if date.nil?
  (date.is_a?(Date) || date.is_a?(Time)) ? (date.is_a?(Time) ? date.in_time_zone(DISPLAY_TIME_ZONE).strftime("%-m/%-d/%Y") : date.strftime("%-m/%-d/%Y")) : date
end

#american_date_time(date) ⇒ Object



34
35
36
37
# File 'app/helpers/fortifier/date_helper.rb', line 34

def american_date_time(date)
  return nil if date.nil?
  (date.is_a?(Date) || date.is_a?(Time)) ? (date.is_a?(Time) ? date.in_time_zone(DISPLAY_TIME_ZONE).strftime("%-m/%-d/%Y %H:%M:%S") : date.strftime("%-m/%-d/%Y %H:%M:%S")) : date
end

#euro_date(date) ⇒ Object

Produces -> 2013-05-21



11
12
13
14
# File 'app/helpers/fortifier/date_helper.rb', line 11

def euro_date(date)
  return nil if date.nil?
  (date.is_a?(Date) || date.is_a?(Time)) ? (date.is_a?(Time) ? date.in_time_zone(DISPLAY_TIME_ZONE).strftime("%Y-%m-%d") : date.strftime("%Y-%m-%d")) : date
end

#format_date_long(date) ⇒ Object



22
23
24
25
26
# File 'app/helpers/fortifier/date_helper.rb', line 22

def format_date_long(date)
  # format example: "July 29, 2013"
  return nil if date.nil?
  (date.is_a?(Date) || date.is_a?(Time)) ? (date.is_a?(Time) ? date.in_time_zone(DISPLAY_TIME_ZONE).strftime("%B %d, %Y") : date.strftime("%B %d, %Y")) : date
end

#format_time_12hr(time) ⇒ Object



28
29
30
31
32
# File 'app/helpers/fortifier/date_helper.rb', line 28

def format_time_12hr(time)
  # format example: "4:41pm"
  return nil if time.nil?
  (time.is_a?(DateTime) || time.is_a?(Time)) ? time.in_time_zone(DISPLAY_TIME_ZONE).strftime("%l:%M%P").gsub(' ','') : time
end

#short_date(date) ⇒ Object

Produces -> 5/21/09



17
18
19
20
# File 'app/helpers/fortifier/date_helper.rb', line 17

def short_date(date)
  return nil if date.nil?
  (date.is_a?(Date) || date.is_a?(Time)) ? (date.is_a?(Time) ? date.in_time_zone(DISPLAY_TIME_ZONE).strftime("%-m/%-d/%y") : date.strftime("%-m/%-d/%y")) : date
end

#short_month_date(date) ⇒ Object

Produces => Mar 10,2010



40
41
42
43
# File 'app/helpers/fortifier/date_helper.rb', line 40

def short_month_date(date)
  return nil if date.nil?
  (date.is_a?(Date) || date.is_a?(Time)) ? (date.is_a?(Time) ? date.in_time_zone(DISPLAY_TIME_ZONE).strftime("%b %-d, %Y") : date.strftime("%b %-d, %Y")) : date
end