Sha256: a1f33458077234032f81df85f17e48d18d0658967b0ea61e78988a9be77586e6

Contents?: true

Size: 985 Bytes

Versions: 11

Compression:

Stored size: 985 Bytes

Contents

# encoding: utf-8
module Mail
  module CommonDate # :nodoc:
    
    module InstanceMethods # :doc:
      
      # Returns a date time object of the parsed date
      def date_time
        ::DateTime.parse("#{element.date_string} #{element.time_string}")
      end

      def default
        date_time
      end
      
      def parse(val = value)
        unless val.blank?
          @element = Mail::DateTimeElement.new(val)
          @tree = @element.tree
        else
          nil
        end
      end

      private
      
      def do_encode(field_name)
        "#{field_name}: #{value}\r\n"
      end
      
      def do_decode
        "#{value}"
      end

      def element
        @element ||= Mail::DateTimeElement.new(value)
      end
      
      # Returns the syntax tree of the Date
      def tree
        @tree ||= element.tree
      end
      
    end
    
    def self.included(receiver) # :nodoc:
      receiver.send :include, InstanceMethods
    end
    
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
mail-2.1.5 lib/mail/fields/common/common_date.rb
mail-2.1.3 lib/mail/fields/common/common_date.rb
kbaum-mail-2.1.2.1 lib/mail/fields/common/common_date.rb
mail-2.1.2 lib/mail/fields/common/common_date.rb
mail-2.1.1 lib/mail/fields/common/common_date.rb
mail-2.1.0 lib/mail/fields/common/common_date.rb
mail-2.0.5 lib/mail/fields/common/common_date.rb
mail-2.0.3 lib/mail/fields/common/common_date.rb
mail-1.6.0 lib/mail/fields/common/common_date.rb
mail-1.5.4 lib/mail/fields/common/common_date.rb
mail-1.5.3 lib/mail/fields/common/common_date.rb