[Cbor] Multiple ways of expressing the same time via draft-bormann-cbor-time-tag

Emile Cormier <emile.cormier.jr@gmail.com> Tue, 06 April 2021 20:35 UTC

Return-Path: <emile.cormier.jr@gmail.com>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost []) by ietfa.amsl.com (Postfix) with ESMTP id 8E0B93A2FAE for <cbor@ietfa.amsl.com>; Tue, 6 Apr 2021 13:35:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.097
X-Spam-Status: No, score=-2.097 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([]) by localhost (ietfa.amsl.com []) (amavisd-new, port 10024) with ESMTP id ETFRUBvEQkPh for <cbor@ietfa.amsl.com>; Tue, 6 Apr 2021 13:35:29 -0700 (PDT)
Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 4F56D3A2FAD for <cbor@ietf.org>; Tue, 6 Apr 2021 13:35:29 -0700 (PDT)
Received: by mail-pj1-x102f.google.com with SMTP id ep1-20020a17090ae641b029014d48811e37so69489pjb.4 for <cbor@ietf.org>; Tue, 06 Apr 2021 13:35:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=8vqogTDrHkXxCNfrbrnrgXU7JGkULFt3j3C1Kgt/fKc=; b=h0/GBYozQB0ek04OCOHNlhIiUnpieqvtdebL3v27/XRXHjD/OKpTBKH23vmRNLwzya xLhAUHLQ6rmkJCCEOaTz3K0khe0HLB1QDagu6eT0YsoKLpAzPgCsEWklmP3HGFi51FeB R09JT8Z/y8sQKFrIF95h1T1Y0GaEHjnWYYHV7bpeJTBTjSdEe8nkDEY66urbHwPLxdpv hdccFn60bcMw60Fs+uDXke9DkE7B/WA0fYmCZGgnAeo7LLH7kcgM6enNSpw6l/aSxgrb voCDLb5Gn0qDdxnaYht1svmZbGj0lJGdhu65OCeBe1VktZM2BERLMJuUwg0dlGPioSVN UJkw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8vqogTDrHkXxCNfrbrnrgXU7JGkULFt3j3C1Kgt/fKc=; b=YeBTlOWO+89/VcsTL3kVoHeXGrzeeJIcZjGVEskUdbuyxpO/ZDeu9zhoV07MGcK5uH q04/kNk8WB9uzSe5YsA96CejiK3Z8pY0c2JtSprB+zBTiaoKE8YCb61vx8FGmXVjslnx GMXD2aTuY80ePFZBhgRrrmj1x4w4R0fHUI5fzpTbFc8iWx/ue5/0DDf8z4UYXY9XtLnZ cYxGyXFUA0SqoVfEO6pEHvjDvygDtgy9gzlfY/bM0CuDQs+R1AG3VTiUdsXQGflZsaGs m3jQMU9hsCDdm6x1hUQE4R6l88dlfgJh3yWrFSPeXIQwtD6fYJwvC/GVqNEqjsRLnz+K FTMg==
X-Gm-Message-State: AOAM531E0Rk7f63DPsKNNfMyWW4kLsBP/Trtc0seCHDNytBNeQfxT6oM A8sTQMLGhc8OC4n9n2P5NSMN3k6vdSYZ6mpWaMxAt5iVTETXXg==
X-Google-Smtp-Source: ABdhPJyfsA7/O9aQfLVdmgYRxkMtdIatfOMWq6TdeCLw3C4OLnMQ+f5hqHPWhd2j+JYyu2SZ6O2ZPwPrY0IsfLgf0I0=
X-Received: by 2002:a17:902:59da:b029:e9:3064:7e02 with SMTP id d26-20020a17090259dab02900e930647e02mr7152726plj.9.1617741327783; Tue, 06 Apr 2021 13:35:27 -0700 (PDT)
MIME-Version: 1.0
From: Emile Cormier <emile.cormier.jr@gmail.com>
Date: Tue, 06 Apr 2021 17:35:17 -0300
Message-ID: <CAM70yxBEvhN9VqbRpMedPMaSjnRf_GQcUAYcfna0kA5=7gRcdw@mail.gmail.com>
To: cbor@ietf.org
Content-Type: multipart/alternative; boundary="0000000000002e5b4305bf53c10e"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/lxN8zxiFV2mNKLlbDYw8Ff1eFI0>
Subject: [Cbor] Multiple ways of expressing the same time via draft-bormann-cbor-time-tag
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 06 Apr 2021 20:35:34 -0000

I'm implementing tags 1001 and 1002 in my C++ library to exchange time
points and durations (refer to

I'm in the situation where I''m not sure which is the "expected" way to
encode time as nanoseconds since the Unix epoch. I'm specifically referring
to std::chrono::system_clock::time_point, which is a 64 bit integer. There
are currently three ways I could encode such a value.

1. The whole number of seconds under Key 1, with the remaining nanoseconds
under Key -9.

2. The total number of nanoseconds under Key -9, with a value of zero under
Key 1.

3. The total number of nanoseconds expressed as a Decimal Fraction under
Key 4.

Option #2 is the easiest and most efficient because it doesn't involve a
division/subtraction calculation. However, a receiver that discards Key -9
will end up with zero seconds. At least with option #1, the receiver will
know the number of whole seconds if Key -9 is ignored.

Option #3 requires that the sender and receiver understand Tag 4 (Decimal
Fraction), or at least the concept of decimal fractions within the context
of tags 1001-1003.

I'm guessing that option #1 is the "canonical" way, but I'm not entirely
sure. Some guidance would be appreciated. Perhaps a few words concerning
this should be added to the standard's text?

On the receiving side, my library would ideally handle all three scenarios.
It's on the sending side I'm more concerned about when I need to
interoperate with CBOR decoders other than mine.

I apologize if this has already been discussed before. I'm a bit late to
the CBOR party. :-)

Emile Cormier