commit baeacee8b7f64411eb53f13e4e31ba3f5364f265
parent 6c7a21df737ed9e5502a87776f55bd46076510c3
Author: Byron Torres <b@torresjrjr.com>
Date: Sat, 8 Jan 2022 22:25:25 +0000
fix format("%N"); add useful layout constants
Signed-off-by: Byron Torres <b@torresjrjr.com>
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/datetime/format.ha b/datetime/format.ha
@@ -13,6 +13,8 @@ use time::chrono;
export def RFC3999: str = "%Y-%m-%dT%H:%M:%S%z";
export def EMAIL: str = "%a, %d %b %Y %H:%M:%S %z";
export def POSIX: str = "%a %b %e %H:%M:%S %Z %Y";
+export def STAMP: str = "%Y-%m-%d %H:%M:%S";
+export def STAMP_NANO: str = "%Y-%m-%d %H:%M:%S.%N";
def WEEKDAYS: [_]str = [
"Monday",
@@ -464,7 +466,7 @@ export fn fmtstream(h: io::handle, layout: str, dt: *datetime) (size | errors::i
case 'n' =>
yield "\n";
case 'N' =>
- yield strconv::itos(nsec(dt));
+ yield fmt::asprintf("{:09}", strconv::itos(nsec(dt)));
case 'p' =>
// TODO: Localization
yield if (hour(dt) < 12) {