Skip to content

Commit

Permalink
Remove today feature as its only goal was to make chrono an optio…
Browse files Browse the repository at this point in the history
…nal dependency which is now also needed by switch-year command.
  • Loading branch information
FXCourel committed Dec 14, 2024
1 parent 9ca3e7b commit 2154129
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[alias]
today = "run --quiet --release --features today -- today"
today = "run --quiet --release -- today"
scaffold = "run --quiet --release -- scaffold"
download = "run --quiet --release -- download"
read = "run --quiet --release -- read"
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ debug = 1

[features]
dhat-heap = ["dhat"]
today = []
test_lib = []

[dependencies]
Expand Down
8 changes: 1 addition & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use advent_of_code::template::commands::{all, download, read, scaffold, solve, switchyear, time};
use advent_of_code::template::Day;
use advent_of_code::template::{ANSI_BOLD, ANSI_RESET};
use args::{parse, AppArguments};

#[cfg(feature = "today")]
use advent_of_code::template::Day;
#[cfg(feature = "today")]
use std::process;

mod args {
Expand Down Expand Up @@ -37,7 +34,6 @@ mod args {
day: Option<Day>,
store: bool,
},
#[cfg(feature = "today")]
Today,
SwitchYear {
year: Year,
Expand Down Expand Up @@ -78,7 +74,6 @@ mod args {
submit: args.opt_value_from_str("--submit")?,
dhat: args.contains("--dhat"),
},
#[cfg(feature = "today")]
Some("today") => AppArguments::Today,
Some("switch-year") => AppArguments::SwitchYear {
year: args.free_from_str()?,
Expand Down Expand Up @@ -133,7 +128,6 @@ fn main() {
dhat,
submit,
} => solve::handle(day, release, dhat, submit),
#[cfg(feature = "today")]
AppArguments::Today => {
match Day::today() {
Some(day) => {
Expand Down
1 change: 0 additions & 1 deletion src/template/commands/switchyear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn handle(year: Year) {
}
}

#[cfg(feature = "today")]
pub fn handle_today() {
let year = Year::this_year().unwrap();
let env_year = Year::new(env::var("AOC_YEAR").unwrap().parse().unwrap()).unwrap();
Expand Down
8 changes: 1 addition & 7 deletions src/template/day.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use chrono::{Datelike, FixedOffset, Utc};
use std::error::Error;
use std::fmt::Display;
use std::str::FromStr;

#[cfg(feature = "today")]
use chrono::{Datelike, FixedOffset, Utc};

#[cfg(feature = "today")]
const SERVER_UTC_OFFSET: i32 = -5;

/// A valid day number of advent (i.e. an integer in range 1 to 25).
Expand Down Expand Up @@ -41,10 +38,7 @@ impl Day {
pub fn into_inner(self) -> u8 {
self.0
}
}

#[cfg(feature = "today")]
impl Day {
/// Returns the current day if it's between the 1st and the 25th of december, `None` otherwise.
pub fn today() -> Option<Self> {
let offset = FixedOffset::east_opt(SERVER_UTC_OFFSET * 3600)?;
Expand Down

0 comments on commit 2154129

Please sign in to comment.