diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index 89f7aab4250a0c..f21fc5bb8dd8b7 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -1894,7 +1894,7 @@ NSTimeInterval MTRTimeIntervalForEventTimestampValue(uint64_t timeValue) uint64_t eventTimestampValueSeconds = timeValue / chip::kMillisecondsPerSecond; uint64_t eventTimestampValueRemainderMilliseconds = timeValue % chip::kMillisecondsPerSecond; NSTimeInterval eventTimestampValueRemainder - = NSTimeInterval(eventTimestampValueRemainderMilliseconds) / chip::kMillisecondsPerSecond; + = NSTimeInterval(eventTimestampValueRemainderMilliseconds / static_cast(chip::kMillisecondsPerSecond)); NSTimeInterval eventTimestampValue = eventTimestampValueSeconds + eventTimestampValueRemainder; return eventTimestampValue; diff --git a/src/darwin/Framework/CHIP/MTRConversion.h b/src/darwin/Framework/CHIP/MTRConversion.h index b0cf1afea40ad1..6f722d04d5a1bb 100644 --- a/src/darwin/Framework/CHIP/MTRConversion.h +++ b/src/darwin/Framework/CHIP/MTRConversion.h @@ -38,7 +38,8 @@ AsNumber(chip::Optional optional) inline NSDate * MatterEpochSecondsAsDate(uint32_t matterEpochSeconds) { - return [NSDate dateWithTimeIntervalSince1970:(chip::kChipEpochSecondsSinceUnixEpoch + (NSTimeInterval) matterEpochSeconds)]; + const uint64_t interval = static_cast(chip::kChipEpochSecondsSinceUnixEpoch) + matterEpochSeconds; + return [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval) interval]; } template diff --git a/src/darwin/Framework/CHIP/MTRConversion.mm b/src/darwin/Framework/CHIP/MTRConversion.mm index 5e657b9330a8e5..3b0b7344314f19 100644 --- a/src/darwin/Framework/CHIP/MTRConversion.mm +++ b/src/darwin/Framework/CHIP/MTRConversion.mm @@ -92,7 +92,7 @@ bool DateToMatterEpochMilliseconds(NSDate * date, uint64_t & matterEpochMillisec bool DateToMatterEpochMicroseconds(NSDate * date, uint64_t & matterEpochMicroseconds) { - uint64_t timeSinceUnixEpoch = static_cast(date.timeIntervalSince1970 * chip::kMicrosecondsPerSecond); + uint64_t timeSinceUnixEpoch = static_cast(date.timeIntervalSince1970 * static_cast(chip::kMicrosecondsPerSecond)); if (timeSinceUnixEpoch < chip::kChipEpochUsSinceUnixEpoch) { // This is a pre-Matter-epoch time, and cannot be represented as an epoch time value. return false;