class TJSON::DataType::Timestamp
RFC3339 timestamp (Z-normalized)
Constants
- TIMESTAMP_REGEX
Regular expression for matching timestamps
Public Instance Methods
decode(str)
click to toggle source
# File lib/tjson/datatype/timestamp.rb, line 14 def decode(str) raise TJSON::TypeError, "expected String, got #{str.class}: #{str.inspect}" unless str.is_a?(::String) raise TJSON::ParseError, "invalid timestamp: #{str.inspect}" unless str =~ TIMESTAMP_REGEX ::Time.iso8601(str) end
encode(timestamp)
click to toggle source
# File lib/tjson/datatype/timestamp.rb, line 21 def encode(timestamp) timestamp.to_time.utc.iso8601 end
tag()
click to toggle source
# File lib/tjson/datatype/timestamp.rb, line 10 def tag "t" end