| 1 |
// SPDX-License-Identifier: MPL-2.0 |
| 2 |
// (c) Hare authors <https://harelang.org> |
| 3 |
|
| 4 |
use time; |
| 5 |
|
| 6 |
// A precise moment in time, in reference to a specific timescale. |
| 7 |
// An extension of [[time::instant]] coupled with a [[timescale]]. |
| 8 |
export type moment = struct { |
| 9 |
time::instant, |
| 10 |
tsc: *timescale, |
| 11 |
}; |
| 12 |
|
| 13 |
// Creates a new [[moment]]. |
| 14 |
export fn new(tsc: *timescale, t: time::instant) moment = { |
| 15 |
return moment { |
| 16 |
sec = t.sec, |
| 17 |
nsec = t.nsec, |
| 18 |
tsc = tsc, |
| 19 |
}; |
| 20 |
}; |
| 21 |
|
| 22 |
// Extracts the [[time::instant]] of the given [[moment]]. |
| 23 |
export fn to_instant(m: moment) time::instant = *(&m: *time::instant); |