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