diff --git a/src/ds323x/datetime.rs b/src/ds323x/datetime.rs index 74523f3..3491ea7 100644 --- a/src/ds323x/datetime.rs +++ b/src/ds323x/datetime.rs @@ -93,8 +93,13 @@ where fn month(&mut self) -> Result { let data = self.iface.read_register(Register::MONTH)?; - let value = data & !BitFlags::CENTURY; - Ok(packed_bcd_to_decimal(value)) + + let century = data & BitFlags::CENTURY; + if century != 0 { + return Err(Error::InvalidDeviceCentury); + } + + Ok(packed_bcd_to_decimal(data)) } fn year(&mut self) -> Result { diff --git a/tests/datetime.rs b/tests/datetime.rs index eb465c3..ec88bdf 100644 --- a/tests/datetime.rs +++ b/tests/datetime.rs @@ -185,12 +185,6 @@ mod month { get_param_test!(get, month, MONTH, 1, 1); read_set_param_test!(set, set_month, MONTH, 12, 0b0000_0010, 0b0001_0010); set_invalid_param_range_test!(invalid, set_month, 0, 13); - - mod keeps_century { - use super::*; - get_param_test!(get, month, MONTH, 12, 0b1001_0010); - read_set_param_test!(set, set_month, MONTH, 12, 0b1000_0010, 0b1001_0010); - } } mod year {