feat: display date

This commit is contained in:
Pihkaal
2024-01-18 23:50:04 +01:00
parent 77aa0417a6
commit 0716720b77
2 changed files with 17 additions and 2 deletions

2
config
View File

@@ -14,7 +14,7 @@ fps=30
# Which color mode to use
# Value: "term", "hex" or "ansi"
color_mode=ansi
color_mode=term
# Loaded if color_mode is set to "term"
# Value: 0-15

View File

@@ -10,7 +10,7 @@ use crossterm::{
cursor,
event::{self, Event, KeyCode, KeyModifiers},
execute, queue,
style::{self, Color},
style::{self, Attribute, Color},
terminal::{self, ClearType},
};
@@ -102,6 +102,21 @@ fn render_frame(config: &Config) -> io::Result<()> {
}
draw_symbol(minute.chars().last().unwrap(), x - 2 + 4 * 7, y, color)?;
// Display date
let date = time.date_naive().format("%Y-%m-%d").to_string();
let mut stdout = io::stdout();
let x = width / 2 - (date.len() as u16) / 2;
let y = height / 2 + text_height / 2 + 2;
queue!(
stdout,
cursor::MoveTo(x, y),
style::SetForegroundColor(color),
style::SetAttribute(Attribute::Bold)
)?;
write!(stdout, "{}", date)?;
return Ok(());
}