Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

jiff: Days in month rangeint should always have range 28-31 #85

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub(crate) fn saturate_day_in_month(
/// February.
pub(crate) fn days_in_month(year: Year, month: Month) -> Day {
if month == 2 && is_leap_year(year) {
Day::N::<29>()
Day::V::<29, 28, 31>()
} else {
days_in_month_common_year(month)
}
Expand Down Expand Up @@ -93,19 +93,19 @@ pub(crate) const fn days_in_month_unranged(year: i16, month: i8) -> i8 {
/// Returns the number of days in the given month for a non-leap year.
pub(crate) fn days_in_month_common_year(month: Month) -> Day {
const BY_MONTH: [Day; 13] = [
Day::N::<0>(),
Day::N::<31>(),
Day::N::<28>(),
Day::N::<31>(),
Day::N::<30>(),
Day::N::<31>(),
Day::N::<30>(),
Day::N::<31>(),
Day::N::<31>(),
Day::N::<30>(),
Day::N::<31>(),
Day::N::<30>(),
Day::N::<31>(),
Day::V::<0, 28, 31>(),
Day::V::<31, 28, 31>(),
Day::V::<28, 28, 31>(),
Day::V::<31, 28, 31>(),
Day::V::<30, 28, 31>(),
Day::V::<31, 28, 31>(),
Day::V::<30, 28, 31>(),
Day::V::<31, 28, 31>(),
Day::V::<31, 28, 31>(),
Day::V::<30, 28, 31>(),
Day::V::<31, 28, 31>(),
Day::V::<30, 28, 31>(),
Day::V::<31, 28, 31>(),
];
BY_MONTH[usize::from(month.get() as u8)]
}
Expand Down