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, +};