AceTime  0.1
Date and time classes for Arduino that supports the TZ DAtabase, and a system clock synchronized from an NTP server or an RTC chip.
time_offset_mutation.h
1 #ifndef ACE_TIME_TIME_OFFSET_MUTATION_H
2 #define ACE_TIME_TIME_OFFSET_MUTATION_H
3 
4 #include <stdint.h>
5 #include "common/util.h"
6 #include "TimeOffset.h"
7 
8 namespace ace_time {
9 namespace time_offset_mutation {
10 
35 inline void incrementHour(TimeOffset& offset) {
36  int8_t code = offset.toOffsetCode();
37  code += 4;
38  if (code >= 64) {
39  code = -code + 4; // preserve the minute component
40  }
41  offset.setOffsetCode(code);
42 }
43 
49 inline void increment15Minutes(TimeOffset& offset) {
50  int8_t code = offset.toOffsetCode();
51  uint8_t ucode = (code < 0) ? -code : code;
52  ucode = (ucode & 0xFC) | (((ucode & 0x03) + 1) & 0x03);
53  offset.setOffsetCode((code < 0) ? -ucode : ucode);
54 }
55 
56 }
57 }
58 
59 #endif