You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation on the NaiveDate::years_since says it Returns None if base < self.. But this is not correct. It is actually Returns None if base > self.. As the implementation is:
pubconstfnyears_since(&self,base:Self) -> Option<u32>{letmut years = self.year() - base.year();// Comparing tuples is not (yet) possible in const context. Instead we combine month and// day into one `u32` for easy comparison.if(self.month() << 5 | self.day()) < (base.month() << 5 | base.day()){
years -= 1;}match years >= 0{true => Some(years asu32),false => None,}}
Base must be bigger than self to return None, take the example of 2022-01-01 and 1998-01-01. If base was 2022 and 1998 self it will be 1998 - 2022 < 0. Which will return None from being negative.
The text was updated successfully, but these errors were encountered:
The documentation on the
NaiveDate::years_since
says itReturns None if base < self.
. But this is not correct. It is actuallyReturns None if base > self.
. As the implementation is:Base must be bigger than self to return None, take the example of 2022-01-01 and 1998-01-01. If base was 2022 and 1998 self it will be
1998 - 2022 < 0
. Which will return None from being negative.The text was updated successfully, but these errors were encountered: