class Mail::CommonDateField
:nodoc:
def self.normalize_datetime(string)
def self.normalize_datetime(string) if Utilities.blank?(string) datetime = ::DateTime.now else stripped = string.to_s.gsub(/\(.*?\)/, '').squeeze(' ') begin datetime = ::DateTime.parse(stripped) rescue ArgumentError => e raise unless 'invalid date' == e.message end end if datetime datetime.strftime('%a, %d %b %Y %H:%M:%S %z') else string end end
def self.singular?
def self.singular? true end
def date_time
def date_time ::DateTime.parse("#{element.date_string} #{element.time_string}") rescue ArgumentError => e raise e unless e.message == 'invalid date' end
def default
def default date_time end
def do_decode
def do_decode value.to_s end
def do_encode
def do_encode "#{name}: #{value}\r\n" end
def element
def element @element ||= Mail::DateTimeElement.new(value) end
def initialize(value = nil, charset = nil)
def initialize(value = nil, charset = nil) super self.class.normalize_datetime(value), charset end