AceTime 3.0.0 Date and time classes for Arduino that support timezones from the TZ Database.

time_period_mutation.h
Go to the documentation of this file.
1 /*
2 * MIT License
3 * Copyright (c) 2018 Brian T. Park
4 */
5
6 #ifndef ACE_TIME_TIME_PERIOD_MUTATION_H
7 #define ACE_TIME_TIME_PERIOD_MUTATION_H
8
9 #include <stdint.h>
10 #include <AceCommon.h>
11 #include "TimePeriod.h"
12
13 namespace ace_time {
14 namespace time_period_mutation {
15
28 inline void negate(TimePeriod& period) {
29 period.sign(-period.sign());
30 }
31
33 inline void incrementHour(TimePeriod& period, uint8_t limit) {
34 uint8_t hour = period.hour();
35 ace_common::incrementMod(hour, limit);
36 period.hour(hour);
37 }
38
40 inline void incrementHour(TimePeriod& period) {
41 incrementHour(period, (uint8_t) 24);
42 }
43
45 inline void incrementMinute(TimePeriod& period) {
46 uint8_t minute = period.minute();
47 ace_common::incrementMod(minute, (uint8_t) 60);
48 period.minute(minute);
49 }
50
51
52 }
53 }
54
55 #endif
ace_time::TimePeriod
Represents a period of time relative to some known point in time, potentially represented by a DateTi...
Definition: TimePeriod.h:27
ace_time::TimePeriod::sign
int8_t sign() const
Return the sign bit.
Definition: TimePeriod.h:122
ace_time::TimePeriod::minute
uint8_t minute() const
Return the minute.
Definition: TimePeriod.h:110
ace_time::TimePeriod::hour
uint8_t hour() const
Return the hour.
Definition: TimePeriod.h:104
ace_time::time_period_mutation::negate
void negate(TimePeriod &period)
Change the sign of the object.
Definition: time_period_mutation.h:28