Sha256: 0045b09ceb77f220ffe9cb20a9f87fb895a0a9df272947208b1e09a8a0e5cdc6

Contents?: true

Size: 476 Bytes

Versions: 28

Compression:

Stored size: 476 Bytes

Contents

module CassandraObject
  module Types
    class TimeWithZoneType < BaseType
      def encode(time)
        raise ArgumentError.new("#{self} requires a Time") unless time.kind_of?(Time)
        time.utc.xmlschema(6)
      end

      def decode(str)
        return nil if str.empty?
        raise ArgumentError.new("Cannot convert #{str} into a Time") unless str.kind_of?(String) && str.match(TimeType::REGEX)
        Time.xmlschema(str).in_time_zone
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
gotime-cassandra_object-2.7.2 lib/cassandra_object/types/time_with_zone_type.rb
gotime-cassandra_object-2.7.1 lib/cassandra_object/types/time_with_zone_type.rb
gotime-cassandra_object-2.7.0 lib/cassandra_object/types/time_with_zone_type.rb
gotime-cassandra_object-2.6.4 lib/cassandra_object/types/time_with_zone_type.rb
gotime-cassandra_object-2.6.3 lib/cassandra_object/types/time_with_zone_type.rb
gotime-cassandra_object-2.6.2 lib/cassandra_object/types/time_with_zone_type.rb
gotime-cassandra_object-2.6.1 lib/cassandra_object/types/time_with_zone_type.rb
gotime-cassandra_object-2.6.0 lib/cassandra_object/types/time_with_zone_type.rb