@@ -3,6 +3,7 @@ pub mod parse;
33pub mod utils;
44
55// Reexport some crates for the generated main
6+ pub use chrono;
67pub use clap;
78pub use colored;
89
@@ -45,6 +46,7 @@ pub fn args(year: u16) -> App<'static> {
4546 . long ( "bench" )
4647 . about ( "Run criterion benchmarks" ) ,
4748 )
49+ . arg ( Arg :: new ( "all" ) . long ( "all" ) . about ( "Run all days" ) )
4850}
4951
5052#[ macro_export]
@@ -54,16 +56,22 @@ macro_rules! base_main {
5456 use std:: io:: Read ;
5557 use std:: time:: Instant ;
5658
59+ use $crate:: chrono:: { prelude:: * , FixedOffset , TimeZone } ;
60+
5761 use $crate:: { bench_day, extract_day, parse, run_day} ;
5862
5963 const YEAR : u16 = $year;
6064
6165 fn main( ) {
6266 let mut opt = $crate:: args( YEAR ) . get_matches( ) ;
6367
68+
6469 if opt. is_present( "bench" ) {
6570 bench( ) ;
6671 } else {
72+ let est = FixedOffset :: west( 5 * 3600 ) . from_utc_datetime( & Utc :: now( ) . naive_utc( ) ) ;
73+ let today = est. day( ) . to_string( ) ;
74+
6775 let days: Vec <_> = {
6876 if let Some ( opt_days) = opt. values_of( "days" ) {
6977 let opt_days: Vec <_> = opt_days. collect( ) ;
@@ -84,10 +92,14 @@ macro_rules! base_main {
8492 . filter( |day| days. contains( & format!( "day{}" , day) . as_str( ) ) )
8593 . collect( )
8694 } else {
87- parse!( extract_day { } ; $( $tail ) * )
88- . iter( )
89- . map( |s| & s[ 3 ..] )
90- . collect( )
95+ if !opt. is_present( "all" ) && est. year( ) == YEAR as i32 && est. month( ) == 12 && est. day( ) <= 25 {
96+ vec![ & today]
97+ } else {
98+ parse!( extract_day { } ; $( $tail ) * )
99+ . iter( )
100+ . map( |s| & s[ 3 ..] )
101+ . collect( )
102+ }
91103 }
92104 } ;
93105
0 commit comments