diff --git a/src/shared_api_lib/src/year_month.rs b/src/shared_api_lib/src/year_month.rs index b86b0c4..820a8b0 100644 --- a/src/shared_api_lib/src/year_month.rs +++ b/src/shared_api_lib/src/year_month.rs @@ -1,3 +1,5 @@ +use chrono::Datelike; + #[derive(Copy, Clone)] pub struct YearMonth { pub year: i32, @@ -39,6 +41,14 @@ impl YearMonth { _ => None, } } + + pub fn today() -> YearMonth { + let now = chrono::prelude::Local::now(); + return YearMonth { + year: now.year(), + month: u8::try_from(now.month()).unwrap(), + }; + } } impl std::fmt::Display for YearMonth {