RTCZero icon indicating copy to clipboard operation
RTCZero copied to clipboard

Setting minutes and hours dont wrap properly

Open jacky4566 opened this issue 6 years ago • 1 comments
trafficstars

I notice there is some weirdness when using the setMinutes, setHours functions.

Using the function rtc.setHours(rtc.getHours()+1);

allows for setting time between 0 and 32. Shouldn't this wrap around at 24?

Code example:

#include <RTCZero.h>

RTCZero rtc;

void setup() {
  rtc.begin(); // initialize RTC
}

void loop() {
  Serial.print(rtc.getHours());
  Serial.print(":");
  Serial.print(rtc.getMinutes());
  Serial.print(":");
  Serial.print(rtc.getSeconds());
  Serial.println();

  rtc.setHours(rtc.getHours() + 1);
  delay(1000);
}

Output

18:05:33
19:05:34
20:05:35
21:05:36
22:05:37
23:05:38
24:05:39 <-- Not a valid time
25:05:40
26:05:41
27:05:42
28:05:43
29:05:44
30:05:45
31:05:46
00:05:47
01:05:48

jacky4566 avatar May 31 '19 19:05 jacky4566

Hello @jacky4566, Can you please test and tell me what happens when you pass a value of more than 32?

Inv3nt0r1 avatar Mar 27 '20 09:03 Inv3nt0r1