How to get the last date of a month with chrono::NaiveDate
. I try to search the manual but can't found anything useful.
use chrono::{NaiveDate, Datelike};
// from January to December m = 1 - 12
for m in 1..=12 {
let end = ..... ??
let start_date = NaiveDate::from_ymd(year, m, 1); /// each month starts with 1
let end_date = NaiveDate::from_ymd(year, m, end); /// here's the problem
container.push((start_date, end_date));
}
the closest would be to use Datelike::day
function and subtract 1 day from it. chrono::Datelike - Rust
but I don't know how to use it with NaiveDate