Parse common UTC timestamps in process

This commit is contained in:
udo
2026-07-17 00:15:43 +00:00
parent 7789385ef5
commit 03ffeeb0da
2 changed files with 30 additions and 1 deletions
+12 -1
View File
@@ -195,11 +195,22 @@ RENDER(Request& context)
}
check("request_perf() stages stable repeated snapshots", perf_stable, json_encode(perf));
u64 shell_exec_before_time_parse = 0;
request_perf()["hostcall_operations"].each([&](DValue operation, String key) {
if(operation["name"].to_string() == "shell_exec")
shell_exec_before_time_parse = operation["count"].to_u64();
});
u64 parsed_epoch = time_parse("1970-01-01 00:00:05 UTC");
u64 parsed_iso_epoch = time_parse("1970-01-01T00:00:05Z");
u64 shell_exec_after_time_parse = 0;
request_perf()["hostcall_operations"].each([&](DValue operation, String key) {
if(operation["name"].to_string() == "shell_exec")
shell_exec_after_time_parse = operation["count"].to_u64();
});
String utc_year = time_format_utc("%Y", parsed_epoch);
String local_year = time_format_local("%Y", parsed_epoch);
String relative = time_format_relative(time() - 120, "recent %deltaS", 1, "medium %deltaM", 3600, "old %deltaH");
check("time_format_local() / time_format_relative() / time_parse()", parsed_epoch == 5 && time_parse("") == 0 && time_parse(" ") == 0 && utc_year == "1970" && local_year != "" && contains(relative, "medium"), "parsed=" + std::to_string(parsed_epoch) + " empty=" + std::to_string(time_parse("")) + " utc=" + utc_year + " local=" + local_year + " rel=" + relative);
check("time_format_local() / time_format_relative() / time_parse()", parsed_epoch == 5 && parsed_iso_epoch == 5 && shell_exec_after_time_parse == shell_exec_before_time_parse && time_parse("") == 0 && time_parse(" ") == 0 && utc_year == "1970" && local_year != "" && contains(relative, "medium"), "parsed=" + std::to_string(parsed_epoch) + " iso=" + std::to_string(parsed_iso_epoch) + " shell=" + std::to_string(shell_exec_before_time_parse) + "/" + std::to_string(shell_exec_after_time_parse) + " empty=" + std::to_string(time_parse("")) + " utc=" + utc_year + " local=" + local_year + " rel=" + relative);
String crypto_random = random_bytes(16);
String crypto_b64 = base64_encode("hello");