AceTime  3.0.0
Date and time classes for Arduino that support timezones from the TZ Database.
offset_date_time_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_OFFSET_DATE_TIME_MUTATION_H
7 #define ACE_TIME_OFFSET_DATE_TIME_MUTATION_H
8 
9 #include <stdint.h>
10 #include <AceCommon.h>
11 #include "OffsetDateTime.h"
12 
13 namespace ace_time {
14 namespace offset_date_time_mutation {
15 
42 inline void incrementYear(OffsetDateTime& dateTime) {
43  int16_t year = dateTime.year();
44  ace_common::incrementModOffset(year, (int16_t) 100, (int16_t) 2000);
45  dateTime.year(year);
46 }
47 
49 inline void incrementMonth(OffsetDateTime& dateTime) {
50  uint8_t month = dateTime.month();
51  ace_common::incrementModOffset(month, (uint8_t) 12, (uint8_t) 1);
52  dateTime.month(month);
53 }
54 
56 inline void incrementDay(OffsetDateTime& dateTime) {
57  uint8_t day = dateTime.day();
58  ace_common::incrementModOffset(day, (uint8_t) 31, (uint8_t) 1);
59  dateTime.day(day);
60 }
61 
63 inline void incrementHour(OffsetDateTime& dateTime) {
64  uint8_t hour = dateTime.hour();
65  ace_common::incrementMod(hour, (uint8_t) 24);
66  dateTime.hour(hour);
67 }
68 
70 inline void incrementMinute(OffsetDateTime& dateTime) {
71  uint8_t minute = dateTime.minute();
72  ace_common::incrementMod(minute, (uint8_t) 60);
73  dateTime.minute(minute);
74 }
75 
76 }
77 }
78 
79 #endif
The date (year, month, day), time (hour, minute, second) and fixed offset from UTC (timeOffset).
uint8_t day() const
Return the day of the month.
uint8_t hour() const
Return the hour.
uint8_t month() const
Return the month with January=1, December=12.
uint8_t minute() const
Return the minute.
int16_t year() const
Return the year.
void incrementMonth(OffsetDateTime &dateTime)
Increment the month by one within the interval [1, 12].
void incrementYear(OffsetDateTime &dateTime)
Increment the year by one within the interval [2000, 2099].
void incrementDay(OffsetDateTime &dateTime)
Increment the day by one within the interval [1, 31].
void incrementHour(OffsetDateTime &dateTime)
Increment the hour by one within the interval [0, 23].
void incrementMinute(OffsetDateTime &dateTime)
Increment the minute by one within the interval [0, 59].