Sha256: 99ac70100d851e83f3429de4ebda1bf90d6c90f50303e284b3ae5baff30a8b0f

Contents?: true

Size: 515 Bytes

Versions: 5

Compression:

Stored size: 515 Bytes

Contents

require 'xommelier'

module Xommelier
  module Common
    # A date-time displayed in RFC 822 format.
    class Time822 < Time
      def self.from_xommelier(value)
        case value
        when String
          value = rfc2822(value) rescue parse(value)
          at(value)
        when Time, Date, DateTime
          at(value.to_time)
        else
          raise TypeError, "Invalid value #{value.inspect} for Time822"
        end
      end

      def to_xommelier
        utc.rfc822
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xommelier-0.1.22 lib/xommelier/common.rb
xommelier-0.1.21 lib/xommelier/common.rb
xommelier-0.1.20 lib/xommelier/common.rb
xommelier-0.1.19 lib/xommelier/common.rb
xommelier-0.1.18 lib/xommelier/common.rb