How to find first day of current month and year using Chrono

Hi,
Is there a way using Chrono I can find first day of current month and year?
Eg., for Nov 2020, first day is Sunday. For Oct 2020 it was Thursday and for Dec 2020 it will be Tuesday.

Found a way

use chrono::{NaiveDate, DateTime, Local, Datelike};

fn main() {
    let local: DateTime<Local> = Local::now();
    let nd = NaiveDate::from_ymd(local.year(), local.month(), 1);
    println!("{:?}", nd.weekday());
}
2 Likes