Module: Mail::Jdec::CommonDateFieldPatch

Defined in:
lib/mail/jdec/fields/common_date_field_patch.rb

Instance Method Summary collapse

Instance Method Details

#date_timeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mail/jdec/fields/common_date_field_patch.rb', line 17

def date_time
  if Jdec.enabled?
    if element
      begin
        ::DateTime.parse("#{element.date_string} #{element.time_string}")
      rescue ArgumentError => e
        require 'time'
        begin
          Time.parse(value).to_datetime
        rescue ArgumentError => e
          nil
        end
      end
    else
      nil
    end
  else
    super
  end
end

#elementObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/mail/jdec/fields/common_date_field_patch.rb', line 6

def element
  super
rescue Mail::Field::ParseError => e
  if Jdec.enabled?
    @errors = [name, value, e]
    @element = nil
  else
    raise e
  end
end