Skip to content

Commit 25ac1f7

Browse files
committed
Fix numbrer of seconds in a day, minor nit
1 parent a913b6a commit 25ac1f7

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/date.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl Date {
578578
return None;
579579
}
580580

581-
let julian_day = const_try_opt!(self.to_julian_day().checked_add(whole_days as i32));
581+
let julian_day = const_try_opt!(self.to_julian_day().checked_add(whole_days as _));
582582
if let Ok(date) = Self::from_julian_day(julian_day) {
583583
Some(date)
584584
} else {
@@ -623,7 +623,7 @@ impl Date {
623623
return None;
624624
}
625625

626-
let julian_day = const_try_opt!(self.to_julian_day().checked_sub(whole_days as i32));
626+
let julian_day = const_try_opt!(self.to_julian_day().checked_sub(whole_days as _));
627627
if let Ok(date) = Self::from_julian_day(julian_day) {
628628
Some(date)
629629
} else {

tests/integration/date.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -772,29 +772,29 @@ fn regression_check() {
772772
fn checked_add_duration() {
773773
// Adding subday duration
774774
assert_eq!(
775-
Date::MIN.checked_add(Duration::new(84_399, 999_999_999)),
775+
Date::MIN.checked_add(Duration::new(86_399, 999_999_999)),
776776
Some(Date::MIN)
777777
);
778778
assert_eq!(
779-
Date::MIN.checked_add(Duration::new(-84_399, -999_999_999)),
779+
Date::MIN.checked_add(Duration::new(-86_399, -999_999_999)),
780780
Some(Date::MIN)
781781
);
782782

783783
assert_eq!(
784-
date!(2021 - 10 - 25).checked_add(Duration::new(84_399, 999_999_999)),
784+
date!(2021 - 10 - 25).checked_add(Duration::new(86_399, 999_999_999)),
785785
Some(date!(2021 - 10 - 25))
786786
);
787787
assert_eq!(
788-
date!(2021 - 10 - 25).checked_add(Duration::new(-84_399, -999_999_999)),
788+
date!(2021 - 10 - 25).checked_add(Duration::new(-86_399, -999_999_999)),
789789
Some(date!(2021 - 10 - 25))
790790
);
791791

792792
assert_eq!(
793-
Date::MAX.checked_add(Duration::new(84_399, 999_999_999)),
793+
Date::MAX.checked_add(Duration::new(86_399, 999_999_999)),
794794
Some(Date::MAX)
795795
);
796796
assert_eq!(
797-
Date::MAX.checked_add(Duration::new(-84_399, -999_999_999)),
797+
Date::MAX.checked_add(Duration::new(-86_399, -999_999_999)),
798798
Some(Date::MAX)
799799
);
800800

@@ -826,29 +826,29 @@ fn checked_add_duration() {
826826
fn checked_sub_duration() {
827827
// Subtracting subday duration
828828
assert_eq!(
829-
Date::MIN.checked_sub(Duration::new(84_399, 999_999_999)),
829+
Date::MIN.checked_sub(Duration::new(86_399, 999_999_999)),
830830
Some(Date::MIN)
831831
);
832832
assert_eq!(
833-
Date::MIN.checked_sub(Duration::new(-84_399, -999_999_999)),
833+
Date::MIN.checked_sub(Duration::new(-86_399, -999_999_999)),
834834
Some(Date::MIN)
835835
);
836836

837837
assert_eq!(
838-
date!(2021 - 10 - 25).checked_sub(Duration::new(84_399, 999_999_999)),
838+
date!(2021 - 10 - 25).checked_sub(Duration::new(86_399, 999_999_999)),
839839
Some(date!(2021 - 10 - 25))
840840
);
841841
assert_eq!(
842-
date!(2021 - 10 - 25).checked_sub(Duration::new(-84_399, -999_999_999)),
842+
date!(2021 - 10 - 25).checked_sub(Duration::new(-86_399, -999_999_999)),
843843
Some(date!(2021 - 10 - 25))
844844
);
845845

846846
assert_eq!(
847-
Date::MAX.checked_sub(Duration::new(84_399, 999_999_999)),
847+
Date::MAX.checked_sub(Duration::new(86_399, 999_999_999)),
848848
Some(Date::MAX)
849849
);
850850
assert_eq!(
851-
Date::MAX.checked_sub(Duration::new(-84_399, -999_999_999)),
851+
Date::MAX.checked_sub(Duration::new(-86_399, -999_999_999)),
852852
Some(Date::MAX)
853853
);
854854

0 commit comments

Comments
 (0)