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

zoned_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_ZONED_DATE_TIME_MUTATION_H
7 #define ACE_TIME_ZONED_DATE_TIME_MUTATION_H
8
9 #include <stdint.h>
10 #include <AceCommon.h>
11 #include "ZonedDateTime.h"
12
13 namespace ace_time {
14 namespace zoned_date_time_mutation {
15
42 inline void incrementYear(ZonedDateTime& 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(ZonedDateTime& 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(ZonedDateTime& 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(ZonedDateTime& 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(ZonedDateTime& 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
ace_time::ZonedDateTime
The date (year, month, day), time (hour, minute, second), and a timeZone object that supports the zon...
Definition: ZonedDateTime.h:36
ace_time::ZonedDateTime::hour
uint8_t hour() const
Return the hour.
Definition: ZonedDateTime.h:188
ace_time::ZonedDateTime::year
int16_t year() const
Return the year.
Definition: ZonedDateTime.h:170
ace_time::ZonedDateTime::day
uint8_t day() const
Return the day of the month.
Definition: ZonedDateTime.h:182
ace_time::ZonedDateTime::minute
uint8_t minute() const
Return the minute.
Definition: ZonedDateTime.h:194
ace_time::ZonedDateTime::month
uint8_t month() const
Return the month with January=1, December=12.
Definition: ZonedDateTime.h:176