| ... | @@ -383,6 +383,12 @@ pub const DateTime = struct { | ... | @@ -383,6 +383,12 @@ pub const DateTime = struct { |
| 383 | x, // unix milli | 383 | x, // unix milli |
| 384 | X, // unix | 384 | X, // unix |
| 385 | }; | 385 | }; |
| | 386 | |
| | 387 | pub fn since(self: Self, other_in_the_past: Self) Duration { |
| | 388 | return Duration{ |
| | 389 | .ms = self.toUnixMilli() - other_in_the_past.toUnixMilli(), |
| | 390 | }; |
| | 391 | } |
| 386 | }; | 392 | }; |
| 387 | | 393 | |
| 388 | pub const format = struct { | 394 | pub const format = struct { |
| ... | @@ -472,3 +478,7 @@ fn wrap(val: u16, at: u16) !u16 { | ... | @@ -472,3 +478,7 @@ fn wrap(val: u16, at: u16) !u16 { |
| 472 | var tmp = val % at; | 478 | var tmp = val % at; |
| 473 | return if (tmp == 0) at else tmp; | 479 | return if (tmp == 0) at else tmp; |
| 474 | } | 480 | } |
| | 481 | |
| | 482 | pub const Duration = struct { |
| | 483 | ms: u64, |
| | 484 | }; |