mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-29 14:05:40 +00:00
Use rem_euclid from std (MSRV: 1.38)
This commit is contained in:
parent
93e2a91618
commit
6045377c75
@ -100,21 +100,6 @@ impl From<Utf8Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
// MSRV: 1.38
|
||||
#[inline]
|
||||
fn rem_euclid(v: i64, rhs: i64) -> i64 {
|
||||
let r = v % rhs;
|
||||
if r < 0 {
|
||||
if rhs < 0 {
|
||||
r - rhs
|
||||
} else {
|
||||
r + rhs
|
||||
}
|
||||
} else {
|
||||
r
|
||||
}
|
||||
}
|
||||
|
||||
/// Number of hours in one day
|
||||
const HOURS_PER_DAY: i64 = 24;
|
||||
/// Number of seconds in one hour
|
||||
|
@ -3,7 +3,7 @@ use std::cmp::Ordering;
|
||||
use super::parser::Cursor;
|
||||
use super::timezone::{LocalTimeType, SECONDS_PER_WEEK};
|
||||
use super::{
|
||||
rem_euclid, Error, CUMUL_DAY_IN_MONTHS_NORMAL_YEAR, DAYS_PER_WEEK, DAY_IN_MONTHS_NORMAL_YEAR,
|
||||
Error, CUMUL_DAY_IN_MONTHS_NORMAL_YEAR, DAYS_PER_WEEK, DAY_IN_MONTHS_NORMAL_YEAR,
|
||||
SECONDS_PER_DAY,
|
||||
};
|
||||
|
||||
@ -589,9 +589,9 @@ impl RuleDay {
|
||||
}
|
||||
|
||||
let week_day_of_first_month_day =
|
||||
rem_euclid(4 + days_since_unix_epoch(year, month, 1), DAYS_PER_WEEK);
|
||||
(4 + days_since_unix_epoch(year, month, 1)).rem_euclid(DAYS_PER_WEEK);
|
||||
let first_week_day_occurence_in_month =
|
||||
1 + rem_euclid(week_day as i64 - week_day_of_first_month_day, DAYS_PER_WEEK);
|
||||
1 + (week_day as i64 - week_day_of_first_month_day).rem_euclid(DAYS_PER_WEEK);
|
||||
|
||||
let mut month_day =
|
||||
first_week_day_occurence_in_month + (week as i64 - 1) * DAYS_PER_WEEK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user