From 6094c777eb7b7fbadbf5102f3872d3ad0a2a630e Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 25 Apr 2023 17:09:27 -0700 Subject: [PATCH] add DateTime.since() --- time.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/time.zig b/time.zig index 8cf292dd0b4f01b1416dfcc673b854d5147fae29..d67ee27b696a0ae5d6c143209c9620d9b78df4c9 100644 --- a/time.zig +++ b/time.zig @@ -383,6 +383,12 @@ pub const DateTime = struct { x, // unix milli X, // unix }; + + pub fn since(self: Self, other_in_the_past: Self) Duration { + return Duration{ + .ms = self.toUnixMilli() - other_in_the_past.toUnixMilli(), + }; + } }; pub const format = struct { @@ -472,3 +478,7 @@ fn wrap(val: u16, at: u16) !u16 { var tmp = val % at; return if (tmp == 0) at else tmp; } + +pub const Duration = struct { + ms: u64, +}; -- 2.54.0