(breaking) std.time fixups and API changes

Remove the constants that assume a base unit in favor of explicit
x_per_y constants.

nanosecond calendar timestamps now use i128 for the type. This affects
fs.File.Stat, std.time.nanoTimestamp, and fs.File.updateTimes.

calendar timestamps are now signed, because the value can be less than
the epoch (the user can set their computer time to whatever they wish).

implement std.os.clock_gettime for Windows when clock id is
CLOCK_CALENDAR.
This commit is contained in:
Andrew Kelley
2020-05-24 20:06:56 -04:00
parent c6e7d0fcfd
commit 53d011fa1a
13 changed files with 191 additions and 170 deletions

View File

@@ -31,10 +31,10 @@ pub const Progress = struct {
output_buffer: [100]u8 = undefined,
/// How many nanoseconds between writing updates to the terminal.
refresh_rate_ns: u64 = 50 * std.time.millisecond,
refresh_rate_ns: u64 = 50 * std.time.ns_per_ms,
/// How many nanoseconds to keep the output hidden
initial_delay_ns: u64 = 500 * std.time.millisecond,
initial_delay_ns: u64 = 500 * std.time.ns_per_ms,
done: bool = true,
@@ -282,24 +282,24 @@ test "basic functionality" {
next_sub_task = (next_sub_task + 1) % sub_task_names.len;
node.completeOne();
std.time.sleep(5 * std.time.millisecond);
std.time.sleep(5 * std.time.ns_per_ms);
node.completeOne();
node.completeOne();
std.time.sleep(5 * std.time.millisecond);
std.time.sleep(5 * std.time.ns_per_ms);
node.completeOne();
node.completeOne();
std.time.sleep(5 * std.time.millisecond);
std.time.sleep(5 * std.time.ns_per_ms);
node.end();
std.time.sleep(5 * std.time.millisecond);
std.time.sleep(5 * std.time.ns_per_ms);
}
{
var node = root_node.start("this is a really long name designed to activate the truncation code. let's find out if it works", null);
node.activate();
std.time.sleep(10 * std.time.millisecond);
std.time.sleep(10 * std.time.ns_per_ms);
progress.refresh();
std.time.sleep(10 * std.time.millisecond);
std.time.sleep(10 * std.time.ns_per_ms);
node.end();
}
}