Fix warnings after chrono upgrade (#30165)

Some functions are now deprecated, so use the suggested ones and do a
general cleanup of the affected lines of code.
This commit is contained in:
Martin Robinson 2023-08-23 02:44:00 +02:00 committed by GitHub
parent 838e0f598c
commit bd2503ceac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 43 deletions

View file

@ -783,11 +783,14 @@ fn max_day_in_month(year_num: i32, month_num: u32) -> Result<u32, ()> {
/// https://html.spec.whatwg.org/multipage/#week-number-of-the-last-day
fn max_week_in_year(year: i32) -> u32 {
match Utc.ymd(year as i32, 1, 1).weekday() {
Weekday::Thu => 53,
Weekday::Wed if is_leap_year(year) => 53,
_ => 52,
}
Utc.with_ymd_and_hms(year as i32, 1, 1, 0, 0, 0)
.earliest()
.map(|date_time| match date_time.weekday() {
Weekday::Thu => 53,
Weekday::Wed if is_leap_year(year) => 53,
_ => 52,
})
.unwrap_or(52)
}
#[inline]