feat: configurable date format
This commit is contained in:
@@ -7,6 +7,7 @@ pub struct Config {
|
||||
pub be_polite: bool,
|
||||
pub fps: u64,
|
||||
pub color: Color,
|
||||
pub date_format: String,
|
||||
}
|
||||
|
||||
pub fn load_from_file(path: &str) -> Config {
|
||||
@@ -17,6 +18,7 @@ pub fn load_from_file(path: &str) -> Config {
|
||||
be_polite: ini.getbool("general", "polite").unwrap().unwrap(),
|
||||
fps: ini.getuint("general", "fps").unwrap().unwrap(),
|
||||
color: load_color(&ini),
|
||||
date_format: ini.get("format", "date").unwrap(),
|
||||
};
|
||||
|
||||
return config;
|
||||
|
||||
@@ -103,7 +103,10 @@ 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 date = time
|
||||
.date_naive()
|
||||
.format(&config.date_format.to_owned())
|
||||
.to_string();
|
||||
let mut stdout = io::stdout();
|
||||
|
||||
let x = width / 2 - (date.len() as u16) / 2;
|
||||
|
||||
Reference in New Issue
Block a user