Skip to content

Commit b7fc575

Browse files
committed
Clamp FatFs dates.
1 parent 511c260 commit b7fc575

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/rtc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ impl embedded_sdmmc::TimeSource for Rtc {
866866
impl fatfs::TimeProvider for Rtc {
867867
fn get_current_date(&self) -> fatfs::Date {
868868
let (year, month, day) = self.date_raw();
869+
let year = (year + 1970).max(1980).min(2107);
869870

870871
fatfs::Date::new(year.into(), month.into(), day.into())
871872
}
@@ -874,6 +875,7 @@ impl fatfs::TimeProvider for Rtc {
874875
let (hour, minute, second) = self.time_raw();
875876
let micro = self.microsecond_raw();
876877
let (year, month, day) = self.date_raw();
878+
let year = (year + 1970).max(1980).min(2107);
877879

878880
let time = fatfs::Time::new(
879881
hour.into(),

0 commit comments

Comments
 (0)