Time added for CBOR::Any and CBOR::Encoder.
parent
0f25c5da9f
commit
df25f8269f
|
@ -28,7 +28,8 @@ struct CBOR::Any
|
|||
Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 |
|
||||
Float32 | Float64 |
|
||||
Array(Any) |
|
||||
Hash(String, Any) | Hash(Any, Any)
|
||||
Hash(String, Any) | Hash(Any, Any) |
|
||||
Time
|
||||
|
||||
# Reads a `CBOR::Any` from a JSON::Any structure.
|
||||
def self.new(json : JSON::Any)
|
||||
|
@ -47,6 +48,8 @@ struct CBOR::Any
|
|||
new value
|
||||
when String
|
||||
new value
|
||||
when Time
|
||||
new value
|
||||
|
||||
when Array(Type)
|
||||
ary = [] of CBOR::Any
|
||||
|
|
|
@ -11,7 +11,6 @@ class CBOR::Encoder
|
|||
end
|
||||
|
||||
def write(cbor : CBOR::Any)
|
||||
# Test each possible value of CBOR::Any
|
||||
write cbor.raw
|
||||
end
|
||||
|
||||
|
@ -45,6 +44,12 @@ class CBOR::Encoder
|
|||
write(value.to_s)
|
||||
end
|
||||
|
||||
def write(value : Time)
|
||||
write(CBOR::Tag::RFC3339Time)
|
||||
write(value.to_rfc3339)
|
||||
end
|
||||
|
||||
|
||||
def write(value : Float32 | Float64)
|
||||
case value
|
||||
when Float32
|
||||
|
|
Loading…
Reference in New Issue