Sha256: 5e21211db3dc59791d9c3e81a4022f54afd349205157d7d75bc5c15ba1428eb5

Contents?: true

Size: 526 Bytes

Versions: 117

Compression:

Stored size: 526 Bytes

Contents

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

      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
      module_function :decode
    end
  end
end

Version data entries

117 entries across 117 versions & 2 rubygems

Version Path
sessionm-cassandra_object-4.0.13 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.12 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.11 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.10 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.9 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-2.7.3 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-2.7.2 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.8 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.7 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.6 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.5 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.4 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.3 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.2 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.1 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-4.0.0 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-2.7.1 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-2.7.0 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-2.6.1 lib/cassandra_object/types/time_with_zone_type.rb
sessionm-cassandra_object-2.6.0 lib/cassandra_object/types/time_with_zone_type.rb