mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.time: add microTimestamp() (#13327)
This commit is contained in:
parent
98b60992b3
commit
b40fc70188
1 changed files with 9 additions and 0 deletions
|
|
@ -73,6 +73,15 @@ pub fn milliTimestamp() i64 {
|
|||
return @intCast(i64, @divFloor(nanoTimestamp(), ns_per_ms));
|
||||
}
|
||||
|
||||
/// Get a calendar timestamp, in microseconds, relative to UTC 1970-01-01.
|
||||
/// Precision of timing depends on the hardware and operating system.
|
||||
/// The return value is signed because it is possible to have a date that is
|
||||
/// before the epoch.
|
||||
/// See `std.os.clock_gettime` for a POSIX timestamp.
|
||||
pub fn microTimestamp() i64 {
|
||||
return @intCast(i64, @divFloor(nanoTimestamp(), ns_per_us));
|
||||
}
|
||||
|
||||
/// Get a calendar timestamp, in nanoseconds, relative to UTC 1970-01-01.
|
||||
/// Precision of timing depends on the hardware and operating system.
|
||||
/// On Windows this has a maximum granularity of 100 nanoseconds.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue