diff options
author | Ellie Huxtable <e@elm.sh> | 2021-03-10 21:24:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 21:24:08 +0000 |
commit | 61607e023fbb916f376a7070f8b1ffd6ffe16849 (patch) | |
tree | eadc28b084e0d07f6e3fd0fcaa4c74f2f840c04c /src/command/stats.rs | |
parent | b42d93dcc88c8faf94dee13c93288d0bab0a7b13 (diff) |
Add config file support (#15)
Diffstat (limited to 'src/command/stats.rs')
-rw-r--r-- | src/command/stats.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/command/stats.rs b/src/command/stats.rs index 19079b8d..694484bc 100644 --- a/src/command/stats.rs +++ b/src/command/stats.rs @@ -10,6 +10,7 @@ use structopt::StructOpt; use crate::local::database::Database; use crate::local::history::History; +use crate::settings::Settings; #[derive(StructOpt)] pub enum Cmd { @@ -70,7 +71,7 @@ fn compute_stats(history: &[History]) -> Result<()> { } impl Cmd { - pub fn run(&self, db: &mut impl Database) -> Result<()> { + pub fn run(&self, db: &mut impl Database, settings: &Settings) -> Result<()> { match self { Self::Day { words } => { let words = if words.is_empty() { @@ -79,7 +80,10 @@ impl Cmd { words.join(" ") }; - let start = parse_date_string(&words, Local::now(), Dialect::Us)?; + let start = match settings.local.dialect.to_lowercase().as_str() { + "uk" => parse_date_string(&words, Local::now(), Dialect::Uk)?, + _ => parse_date_string(&words, Local::now(), Dialect::Us)?, + }; let end = start + Duration::days(1); let history = db.range(start.into(), end.into())?; |