authorgravatar for 11590808+mllken@users.noreply.github.comEric Milliken <11590808+mllken@users.noreply.github.com> 2022-11-02 22:20:19+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-11-02 23:20:19+01:00
logb40fc70188fd097e9e05b5c18b635b67b718380e
treeb829f466324a689e4d9acb656e675e1681937570
parent98b60992b334df16db1c7f99be466d252d61c4bc
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

std.time: add microTimestamp() (#13327)


1 files changed, 9 insertions(+), 0 deletions(-)

lib/std/time.zig+9
...@@ -73,6 +73,15 @@ pub fn milliTimestamp() i64 {...@@ -73,6 +73,15 @@ pub fn milliTimestamp() i64 {
73 return @intCast(i64, @divFloor(nanoTimestamp(), ns_per_ms));73 return @intCast(i64, @divFloor(nanoTimestamp(), ns_per_ms));
74}74}
7575
76/// Get a calendar timestamp, in microseconds, relative to UTC 1970-01-01.
77/// Precision of timing depends on the hardware and operating system.
78/// The return value is signed because it is possible to have a date that is
79/// before the epoch.
80/// See `std.os.clock_gettime` for a POSIX timestamp.
81pub fn microTimestamp() i64 {
82 return @intCast(i64, @divFloor(nanoTimestamp(), ns_per_us));
83}
84
76/// Get a calendar timestamp, in nanoseconds, relative to UTC 1970-01-01.85/// Get a calendar timestamp, in nanoseconds, relative to UTC 1970-01-01.
77/// Precision of timing depends on the hardware and operating system.86/// Precision of timing depends on the hardware and operating system.
78/// On Windows this has a maximum granularity of 100 nanoseconds.87/// On Windows this has a maximum granularity of 100 nanoseconds.