Skip to content

Commit bd8e9c3

Browse files
committed
Make getters const
Former-commit-id: d93d9bb
1 parent 696c775 commit bd8e9c3

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

libraries/RTC/src/RTC.h

+9-12
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,18 @@ class RTCTime {
9494
bool setDayOfWeek(DayOfWeek d);
9595
bool setSaveLight(SaveLight sl);
9696
bool setUnixTime(time_t time);
97-
9897
void setTM(struct tm &t);
99-
/* getters */
100-
int getDayOfMonth();
101-
Month getMonth();
102-
int getYear();
103-
int getHour();
104-
int getMinutes();
105-
int getSeconds();
106-
DayOfWeek getDayOfWeek();
107-
98+
99+
/* Getters */
100+
int getDayOfMonth() const;
101+
Month getMonth() const;
102+
int getYear() const;
103+
int getHour() const;
104+
int getMinutes() const;
105+
int getSeconds() const;
106+
DayOfWeek getDayOfWeek() const;
108107
time_t getUnixTime();
109108
struct tm getTmTime();
110-
};
111-
112109

113110

114111
enum class Period {

libraries/RTC/src/RTClock.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,13 @@ bool RTCTime::setUnixTime(time_t time) {
350350
}
351351

352352
/* getters */
353-
int RTCTime::getDayOfMonth() { return day; }
354-
Month RTCTime::getMonth() { return month; }
355-
int RTCTime::getYear() { return year >= TM_YEAR_OFFSET ? year : year + TM_YEAR_OFFSET; }
356-
int RTCTime::getHour() { return hours; }
357-
int RTCTime::getMinutes() { return minutes; }
358-
int RTCTime::getSeconds() { return seconds; }
359-
DayOfWeek RTCTime::getDayOfWeek() { return day_of_week; }
353+
int RTCTime::getDayOfMonth() const { return day; }
354+
Month RTCTime::getMonth() const { return month; }
355+
int RTCTime::getYear() const { return year >= TM_YEAR_OFFSET ? year : year + TM_YEAR_OFFSET; }
356+
int RTCTime::getHour() const { return hours; }
357+
int RTCTime::getMinutes() const { return minutes; }
358+
int RTCTime::getSeconds() const { return seconds; }
359+
DayOfWeek RTCTime::getDayOfWeek() const { return day_of_week; }
360360

361361
time_t RTCTime::getUnixTime() { return mktime ( (struct tm *)&stime ); }
362362
struct tm RTCTime::getTmTime() { return (struct tm)stime; }

0 commit comments

Comments
 (0)