现在我用的是
use chrono::{DateTime, Utc};
pub fn today_three_years_earlier() -> DateTime<Utc> {
let now = Utc::now();
// this is February 29 and it doesn't work of course
// let now = DateTime::from_timestamp(1_709_228_325, 0).unwrap();
let from = now.with_year(now.year() - 3).unwrap();
from
}
但如果现在(今天)是2月29日,它当然不起作用,因为我只是从今天起go 掉3年.
How can I subtract exactly 3 years from now's date?个
It would also be enough for me to remove 365 days * 3 years (without considering leap years).个