Sha256: 701c6aee2caeb50bbdf833fc5d2cb82fc5c989265ff21b98c8595b34ea783971

Contents?: true

Size: 395 Bytes

Versions: 1

Compression:

Stored size: 395 Bytes

Contents

module Superstore
  module Types
    class TimeType < Base
      def serialize(time)
        time.utc.xmlschema(6) if time
      end

      def deserialize(str)
        Time.rfc3339(str).in_time_zone if str
      rescue ArgumentError
        Time.parse(str).in_time_zone rescue nil
      end

      def cast_value(value)
        value.to_time.in_time_zone rescue nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superstore-3.0.0 lib/superstore/types/time_type.rb