Fix chrono deprecations
This commit is contained in:
parent
90b02a9ab8
commit
ebcd5e63fb
|
|
@ -19,8 +19,12 @@ struct Date {
|
||||||
|
|
||||||
impl Date {
|
impl Date {
|
||||||
fn months_since(self, other: Date) -> Option<u32> {
|
fn months_since(self, other: Date) -> Option<u32> {
|
||||||
let self_chrono = Utc.ymd(self.year.try_into().unwrap(), self.month, 1);
|
let self_chrono = Utc
|
||||||
let other_chrono = Utc.ymd(other.year.try_into().unwrap(), other.month, 1);
|
.with_ymd_and_hms(self.year.try_into().unwrap(), self.month, 1, 0, 0, 0)
|
||||||
|
.unwrap();
|
||||||
|
let other_chrono = Utc
|
||||||
|
.with_ymd_and_hms(other.year.try_into().unwrap(), other.month, 1, 0, 0, 0)
|
||||||
|
.unwrap();
|
||||||
let duration_since = self_chrono.signed_duration_since(other_chrono);
|
let duration_since = self_chrono.signed_duration_since(other_chrono);
|
||||||
let months_since = duration_since.num_days() / 30;
|
let months_since = duration_since.num_days() / 30;
|
||||||
if months_since < 0 {
|
if months_since < 0 {
|
||||||
|
|
@ -133,7 +137,7 @@ fn main() {
|
||||||
let root_dir = args.nth(1).unwrap();
|
let root_dir = args.nth(1).unwrap();
|
||||||
let root_dir_path = Path::new(&root_dir);
|
let root_dir_path = Path::new(&root_dir);
|
||||||
let glob_pat = format!("{}/**/*.md", root_dir);
|
let glob_pat = format!("{}/**/*.md", root_dir);
|
||||||
let today_chrono = Utc::today();
|
let today_chrono = Utc::now().date_naive();
|
||||||
let current_month = Date {
|
let current_month = Date {
|
||||||
year: today_chrono.year_ce().1,
|
year: today_chrono.year_ce().1,
|
||||||
month: today_chrono.month(),
|
month: today_chrono.month(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue