hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 68cc24d912c3bf5636ad9633c9d831630f7a09b8
parent 63a5a771b6d8abb183e3bbe82a4edffdb95cacab
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 23 May 2021 15:20:48 -0400

time: implement time::add

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mscripts/gen-stdlib | 1+
Mstdlib.mk | 2++
Atime/arithm.ha | 7+++++++
3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib @@ -690,6 +690,7 @@ time() { gen_srcs time \ '$(PLATFORM)/functions.ha' \ '$(PLATFORM)/$(ARCH).ha' \ + arithm.ha \ types.ha gen_ssa time linux::vdso } diff --git a/stdlib.mk b/stdlib.mk @@ -969,6 +969,7 @@ $(HARECACHE)/temp/temp.ssa: $(stdlib_temp_srcs) $(stdlib_rt) $(stdlib_crypto_ran stdlib_time_srcs= \ $(STDLIB)/time/$(PLATFORM)/functions.ha \ $(STDLIB)/time/$(PLATFORM)/$(ARCH).ha \ + $(STDLIB)/time/arithm.ha \ $(STDLIB)/time/types.ha $(HARECACHE)/time/time.ssa: $(stdlib_time_srcs) $(stdlib_rt) $(stdlib_linux_vdso) @@ -2041,6 +2042,7 @@ $(TESTCACHE)/temp/temp.ssa: $(testlib_temp_srcs) $(testlib_rt) $(testlib_crypto_ testlib_time_srcs= \ $(STDLIB)/time/$(PLATFORM)/functions.ha \ $(STDLIB)/time/$(PLATFORM)/$(ARCH).ha \ + $(STDLIB)/time/arithm.ha \ $(STDLIB)/time/types.ha $(TESTCACHE)/time/time.ssa: $(testlib_time_srcs) $(testlib_rt) $(testlib_linux_vdso) diff --git a/time/arithm.ha b/time/arithm.ha @@ -0,0 +1,7 @@ +// Adds a [[duration]] to an [[instant]], returning an instant further in the +// future (given a positive duration), or further in the past (given a negative +// duration). +export fn add(a: instant, b: duration) instant = instant { + sec = a.sec + b / SECOND, + nsec = a.nsec + b, +};