summaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/command')
-rw-r--r--src/command/mod.rs5
-rw-r--r--src/command/stats.rs8
2 files changed, 9 insertions, 4 deletions
diff --git a/src/command/mod.rs b/src/command/mod.rs
index 0952540b..c74b138f 100644
--- a/src/command/mod.rs
+++ b/src/command/mod.rs
@@ -3,6 +3,7 @@ use structopt::StructOpt;
use uuid::Uuid;
use crate::local::database::Database;
+use crate::settings::Settings;
mod history;
mod import;
@@ -39,12 +40,12 @@ pub fn uuid_v4() -> String {
}
impl AtuinCmd {
- pub fn run(self, db: &mut impl Database) -> Result<()> {
+ pub fn run(self, db: &mut impl Database, settings: &Settings) -> Result<()> {
match self {
Self::History(history) => history.run(db),
Self::Import(import) => import.run(db),
Self::Server(server) => server.run(),
- Self::Stats(stats) => stats.run(db),
+ Self::Stats(stats) => stats.run(db, settings),
Self::Init => init::init(),
Self::Uuid => {
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())?;