Skip to content

Commit b60652d

Browse files
committed
Simplify logic based on PR comments
1 parent 3dc9d76 commit b60652d

File tree

3 files changed

+15
-54
lines changed

3 files changed

+15
-54
lines changed

Cargo.lock

Lines changed: 1 addition & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ bench = ["criterion"]
1515

1616
[dependencies]
1717
attohttpc = { version = "0.16.0", default_features = false, features = ["tls"] }
18-
chrono = "0.4"
1918
clap = { version = "3.0.0-beta.2", default_features = false, features = ["std"] }
2019
colored = "2.0.0"
2120
dirs = "3.0.1"

src/lib.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub mod parse;
33
pub mod utils;
44

55
// Reexport some crates for the generated main
6-
pub use chrono;
76
pub use clap;
87
pub use colored;
98

@@ -46,7 +45,13 @@ pub fn args(year: u16) -> App<'static> {
4645
.long("bench")
4746
.about("Run criterion benchmarks"),
4847
)
49-
.arg(Arg::new("all").long("all").about("Run all days"))
48+
.arg(
49+
Arg::new("all")
50+
.short('a')
51+
.long("all")
52+
.conflicts_with("days")
53+
.about("Run all days"),
54+
)
5055
}
5156

5257
#[macro_export]
@@ -56,22 +61,16 @@ macro_rules! base_main {
5661
use std::io::Read;
5762
use std::time::Instant;
5863

59-
use $crate::chrono::{prelude::*, FixedOffset, TimeZone};
60-
6164
use $crate::{bench_day, extract_day, parse, run_day};
6265

6366
const YEAR: u16 = $year;
6467

6568
fn main() {
6669
let mut opt = $crate::args(YEAR).get_matches();
6770

68-
6971
if opt.is_present("bench") {
7072
bench();
7173
} else {
72-
let est = FixedOffset::west(5 * 3600).from_utc_datetime(&Utc::now().naive_utc());
73-
let today = est.day().to_string();
74-
7574
let days: Vec<_> = {
7675
if let Some(opt_days) = opt.values_of("days") {
7776
let opt_days: Vec<_> = opt_days.collect();
@@ -92,13 +91,17 @@ macro_rules! base_main {
9291
.filter(|day| days.contains(&format!("day{}", day).as_str()))
9392
.collect()
9493
} else {
95-
if !opt.is_present("all") && est.year() == YEAR as i32 && est.month() == 12 && est.day() <= 25 {
96-
vec![&today]
97-
} else {
94+
if opt.is_present("all") {
9895
parse!(extract_day {}; $( $tail )*)
9996
.iter()
10097
.map(|s| &s[3..])
10198
.collect()
99+
} else {
100+
vec![parse!(extract_day {}; $( $tail )*)
101+
.iter()
102+
.map(|s| &s[3..])
103+
.last()
104+
.expect("No day implemenations found")]
102105
}
103106
}
104107
};

0 commit comments

Comments
 (0)