class Forme::Serializer::AmericanTime
Overrides formatting of dates and times to use an American format without timezones.
Public Instance Methods
call(tag)
click to toggle source
Calls superclass method
Forme::Serializer#call
# File lib/forme/transformers/serializer.rb 89 def call(tag) 90 case tag 91 when Tag 92 if tag.type.to_s == 'input' && %w'date datetime datetime-local'.include?((tag.attr[:type] || tag.attr['type']).to_s) 93 attr = tag.attr.dup 94 attr.delete(:type) 95 attr.delete('type') 96 attr['type'] = 'text' 97 "<#{tag.type}#{attr_html(attr)}/>" 98 else 99 super 100 end 101 else 102 super 103 end 104 end
Private Instance Methods
format_date(date)
click to toggle source
Return a string in American format representing the Date
instance.
# File lib/forme/transformers/serializer.rb 109 def format_date(date) 110 date.strftime("%m/%d/%Y") 111 end
format_time(time)
click to toggle source
Return a string in American format representing the Time
or DateTime
instance, without the timezone.
# File lib/forme/transformers/serializer.rb 114 def format_time(time) 115 time.strftime("%m/%d/%Y %I:%M:%S%p") 116 end