dahomey-technologies / Dahomey.Cbor

High-performance CBOR (RFC 8949) serialization framework for .Net (C#)
MIT License
81 stars 14 forks source link

Storing a DateTime in CborValue/CborObject #114

Closed dekenless closed 1 year ago

dekenless commented 1 year ago

Is it possible to store a DateTime in CborValue/CborObject?

mcatanzariti commented 1 year ago

Hi @dekenless,

A CborValue is a generic object model meant to represent CBOR basic types.

Date & time are not part of CBOR basic types. However you could represent a DateTime either in a CBOR String in its ISO representation or in a CBOR integer in its Unix time representation. Alternatively you could also opt for a CBOR double to represent milliseconds in the fractional part of the double.

mcatanzariti commented 1 year ago

Hi @dekenless,

A CborValue is a generic object model meant to represent CBOR basic types.

Date & time are not part of CBOR basic types. However you could represent a DateTime either in a CBOR String in its ISO representation or in a CBOR integer in its Unix time representation. Alternatively you could also opt for a CBOR double to represent milliseconds in the fractional part of the double.