hare

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

commit 4e1fed8d369de1648fd56fe9921b3dbb42451ec5
parent 14d21786e315df4e9ebfcd24e51fcaeb8e4c0147
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 14 Mar 2021 13:28:01 -0400

hare::module: write mtime to manifest

Diffstat:
Mhare/module/manifest.ha | 6+++---
Mtime/types.ha | 9+++++++++
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha @@ -43,9 +43,9 @@ export fn manifest_write(ctx: *context, manifest: *manifest) (void | error) = { defer free(hash); assert(input.stat.mask & fs::stat_mask::INODE == fs::stat_mask::INODE); - // TODO: Add mtime - fmt::fprintfln(fd, "input {} {} {}", - hash, input.path, input.stat.inode); + fmt::fprintfln(fd, "input {} {} {} {}", + hash, input.path, input.stat.inode, + time::unix(input.stat.mtime)); }; for (let i = 0z; i < len(manifest.versions); i += 1) { diff --git a/time/types.ha b/time/types.ha @@ -22,6 +22,15 @@ export fn compare(a: time, b: time) int = { if (a.nsec < b.nsec) -1 else if (a.nsec > b.nsec) 1 else 0; }; +// Converts the given [time] to a Unix timestamp. +export fn unix(a: time) i64 = a.sec; + +// Returns a [time] from a Unix timestamp. +export fn from_unix(u: i64) time = time { + sec = u, + nsec = 0, +}; + @test fn compare() void = { let a = now(clock::MONOTONIC); sleep(1 * MILLISECOND);