class Mail::DateField - mail-2.5.4 Documentation

# class Mail::DateField

### Constants

CAPITALIZED_FIELD
FIELD_NAME

### Public Class Methods

new(value = nil, charset = 'utf-8') click to toggle source
Calls superclass method

    # File lib/mail/fields/date_field.rb, line 33
    def initialize(value = nil, charset = 'utf-8')
      self.charset = charset
      if value.blank?
        value = ::DateTime.now.strftime('%a, %d %b %Y %H:%M:%S %z')
      else
        value = strip_field(FIELD_NAME, value)
        value.to_s.gsub!(/\(.*?\)/, '')
        value = ::DateTime.parse(value.to_s.squeeze(" ")).strftime('%a, %d %b %Y %H:%M:%S %z')
      end
      super(CAPITALIZED_FIELD, value, charset)
    rescue ArgumentError => e
      raise e unless "invalid date"==e.message
    end

### Public Instance Methods

decoded() click to toggle source

    # File lib/mail/fields/date_field.rb, line 51
    def decoded
      do_decode
    end

encoded() click to toggle source

    # File lib/mail/fields/date_field.rb, line 47
    def encoded
      do_encode(CAPITALIZED_FIELD)
    end