commit 3aca263435cf835762b11e51852d88344a3aa6af
parent bda33578fb3f93d4f2a652a14ba2aeaa9ceebb31
Author: Autumn! <autumnull@posteo.net>
Date: Mon, 8 May 2023 17:29:05 +0000
time: add INSTANT_MIN, INSTANT_MAX
Signed-off-by: Autumn! <autumnull@posteo.net>
Diffstat:
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git a/time/types.ha b/time/types.ha
@@ -1,6 +1,7 @@
// License: MPL-2.0
// (c) 2021 Alexey Yerin <yyp@disroot.org>
// (c) 2021 Drew DeVault <sir@cmpwn.com>
+use types;
// The elapsed time between two instants, in nanoseconds. The largest
// representable duration is about 290 years.
@@ -24,6 +25,21 @@ export def MINUTE: duration = 60 * SECOND;
// [[duration]] representing an hour.
export def HOUR: duration = 60 * MINUTE;
+// TODO: change the following to defs when compileable.
+// https://git.sr.ht/~sircmpwn/harec/tree/211b99a/item/src/typedef.c#L169
+
+// The earliest representable [[instant]].
+export const INSTANT_MIN = instant {
+ sec = types::I64_MIN,
+ nsec = 0,
+};
+
+// The latest representable [[instant]].
+export const INSTANT_MAX = instant {
+ sec = types::I64_MAX,
+ nsec = SECOND - 1,
+};
+
// Represents a specific instant in time as seconds (+nanoseconds) since an
// arbitrary epoch. Instants may only be meaningfully compared with other
// instants sourced from the same clock, or handled by the same