Skip to content

Commit

Permalink
night owl config
Browse files Browse the repository at this point in the history
  • Loading branch information
anesthetice committed Jun 14, 2024
1 parent 9e96e22 commit e5264b4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "syracuse"
version = "2.1.2"
version = "2.1.3"
edition = "2021"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ pub fn process_update_subcommand(arg_matches: &ArgMatches, entries: &Entries, to
entry.save()?;
println!("{} : {} {} {}", &date, &tmp, "――>".green(), ns_to_pretty_string(entry.get_block_duration(&date)))
}
else if ["sub", "rem", "remove", "minus", "decr", "decrease"].iter().any(|s| *s == operation) {
else if ["sub", "rm", "rem", "remove", "minus", "decr", "decrease"].iter().any(|s| *s == operation) {
let tmp = ns_to_pretty_string(entry.get_block_duration(&date));
entry.decrease_bloc_duration(&date, total_diff);
entry.save()?;
Expand Down Expand Up @@ -449,7 +449,7 @@ pub fn process_backup_subcommand(arg_matches: &ArgMatches, entries: &Entries, to
info!("directory already exists, this is not feasible");
}
}
println!("backing up to: '{:?}'", &path);
println!("backing up to: '{}'", &path.display());

entries.backup(path);
Ok(PO::Terminate)
Expand Down
7 changes: 6 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub struct Config {
// realistically this could also just be an argument option in the CLI, but I personally want
// it to be always on, so there we go..
pub stopwatch_explicit: bool,
// by how many hours should the day be extended after midnight
// e.g. 2 -> timers started until 2 a.m. on a given day will count towards the previous day
// useful for night owls
pub night_owl_hour_extension: u8,

// threshold for results to be considered
pub search_threshold: f64,
Expand Down Expand Up @@ -72,6 +76,7 @@ impl Default for Config {
local_offset: [0, 0, 0],
backup_path: "".to_string(),
stopwatch_explicit: false,
night_owl_hour_extension: 0,
search_threshold: 0.0,
sw_nw_ratio: 0.5,
match_score: 2,
Expand Down Expand Up @@ -104,7 +109,7 @@ impl Default for Config {
(250, 234, 93),
// mountain lake green
(117, 185, 150),
// ceulean
// cerulean
(0, 143, 190),
]
}
Expand Down
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use directories::ProjectDirs;
use cli::{
process_add_subcommand, process_backup_subcommand, process_graph_subcommand, process_list_subcommand, process_prune_subcommand, process_remove_subcommand, process_start_subcommand, process_today_subcommand, process_update_subcommand, ProcessOutput as PO
};
use data::internal::Entries;
use data::{internal::Entries, syrtime::SyrDate};
fn main() -> anyhow::Result<()> {
// start of initialization
let dirs = ProjectDirs::from("", "", "syracuse").context("failed to get project directories")?;
Expand All @@ -39,8 +39,15 @@ fn main() -> anyhow::Result<()> {
},
}
};
let date = datetime.date().into();
let time = datetime.time();
let date: SyrDate = {
if time.hour() < config::Config::get().night_owl_hour_extension {
datetime.date().previous_day().unwrap_or(datetime.date()).into()
}
else {
datetime.date().into()
}
};

let entries = Entries::load()?;
// end of initialization
Expand Down

0 comments on commit e5264b4

Please sign in to comment.