feat: configurable date format
This commit is contained in:
7
config
7
config
@@ -10,6 +10,13 @@ polite=true
|
||||
# Value: int
|
||||
fps=30
|
||||
|
||||
|
||||
[format]
|
||||
|
||||
# Date format
|
||||
# Value: TODO
|
||||
date=%Y-%m-%d
|
||||
|
||||
[styling]
|
||||
|
||||
# Which color mode to use
|
||||
|
||||
@@ -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