Subject: [Cbor] Tag for Nanoseconds Since Unix Epoch in Int64 Range
From: Faye Amacker <[email-masked]>
To: [email-masked]
Date: Sun, 10 Aug 2025 17:47:43 -0500
List-Id: "Concise Binary Object Representation (CBOR)" <cbor.ietf.org>

Hello,

I maintain a generic CBOR codec[1] and collected some feedback/issues that
might be resolved by using a new CBOR tag (if approved).

Currently, CBOR can encode time with nanoseconds as:
- CBOR tag 0 with text string that is ~30 bytes long (vs ~8 bytes in other
formats)
- CBOR tag 1 with a floating point value that can be lossy (e.g., fails
round trip in fuzz tests and serialization format comparison tests)

A simple way to resolve these is by using a CBOR tag for nanoseconds
elapsed since Unix epoch as an integer in the range -2^63..2^63-1
inclusive.  This allows efficient and lossless encoding of nanoseconds
that can represent time from Sept. 1677 to April 2262.  The tag can be
applied to an unsigned integer (major type 0) or a negative integer (major
type 1).

I wrote a draft proposal[2] with more details. It includes "Rationale"
section with alternatives considered and an "Examples" section that
mentions considerations for negative values.

Thoughts?

[1] https://github.com/fxamacker/cbor
[2]
https://github.com/fxamacker/CBOR-Tag-Specs/blob/master/TimeUnixNanoInt64.md