Sha256: 1543ff5eaa5bb91721ec6c8a45c206a77e1933178cddac3ee5e252947730882e
Contents?: true
Size: 674 Bytes
Versions: 30
Compression:
Stored size: 674 Bytes
Contents
module CassandraObject module Types class TimeType < BaseType REGEX = /\A\s* (-?\d+)-(\d\d)-(\d\d) T (\d\d):(\d\d):(\d\d) (\.\d*)? (Z|[+-]\d\d:\d\d)? \s*\z/ix def encode(time) raise ArgumentError.new("#{time.inspect} is not 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
30 entries across 30 versions & 1 rubygems