Skip to content

Commit

Permalink
util: days in month rangeint should always have range 28-31
Browse files Browse the repository at this point in the history
PR #85
  • Loading branch information
nakedible authored Aug 8, 2024
1 parent bd2b826 commit 224eee9
Showing 1 changed file with 14 additions and 14 deletions.
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

0 comments on commit 224eee9

Please sign in to comment.