From 218f470041cf622285f4a535c1b3cc92d9bc5ebc Mon Sep 17 00:00:00 2001
From: Paul Schulze
Date: Fri, 12 Aug 2022 17:33:06 +0200
Subject: [PATCH] [dev] save time format string in constant
---
src/main.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index a19dd56..def4f56 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,6 +13,8 @@ use std::{
},
};
+const TIME_FORMAT: &str = "%H:%M:%S%.6f";
+
type LogtimesResult = Result<(), IoError>;
#[inline(always)]
@@ -20,14 +22,14 @@ fn print_time(output: &mut T) -> LogtimesResult
where
T: Write,
{
- let date_now = Local::now().format("%H:%M:%S%.6f");
+ let date_now = Local::now().format(TIME_FORMAT);
write!(output, "[{}] ", &date_now)
}
#[inline(always)]
fn print_time_color(output: &mut StdoutLock) -> Result<(), std::io::Error> {
- let date_now = Local::now().format("%H:%M:%S%.6f");
+ let date_now = Local::now().format(TIME_FORMAT);
let color_green = "\x1b\x5b\x30\x3b\x33\x32\x6d";
let color_off = "\x1b\x5b\x30\x6d";