Go to the documentation of this file. 1 #ifndef UNTITLED_DATETIME_H
2 #define UNTITLED_DATETIME_H
35 #define DELTA_TIME(time1, time2) \
36 ((time_t)((time1) - (time2)))
41 #define MILLIS_PER_SEC 1000UL
42 #define SECS_PER_MIN 60UL
44 #define MINS_PER_HOUR 60UL
46 #define HOURS_PER_DAY 24UL
50 #define MILLIS_PER_MIN (MILLIS_PER_SEC * SECS_PER_MIN)
51 #define MILLIS_PER_HOD (MILLIS_PER_MIN * MINS_PER_HOUR)
53 #define MILLIS_PER_DAY (MILLIS_PER_HOD * HOURS_PER_DAY)
61 #define SEC_TO_MILLIS(s) ((time_t)(s) * MILLIS_PER_SEC)
66 #define MIN_TO_MILLIS(m) ((time_t)(m) * MILLIS_PER_MIN)
71 #define HOD_TO_MILLIS(h) ((time_t)(h) * MILLIS_PER_HOD)
76 #define DAY_TO_MILLIS(d) ((time_t)(d) * MILLIS_PER_DAY)
85 #define MILLIS(time) ((time) % MILLIS_PER_SEC)
92 #define SECS(time) (((time) / MILLIS_PER_SEC) % SECS_PER_MIN)
99 #define MINS(time) (((time) / MILLIS_PER_MIN) % MINS_PER_HOUR)
106 #define HOURS(time) (((time) / MILLIS_PER_HOD) % HOURS_PER_DAY)
113 #define DAYS(time) ((time) / MILLIS_PER_DAY)
122 #define FORMAT_2_DIGITS(x) \
123 ((x) >= 10 ? String(x) : ("0" + String(x)))
133 #define FORMAT_3_DIGITS(x) \
134 ((x) >= 100 ? String(x) : ( \
135 (x) >= 10 ? ("0" + String(x)) : ("00" + String(x))))
141 #define FORMAT_TIME(time) \
142 (String(DAYS(time)) + ":" + \
143 String(FORMAT_2_DIGITS(HOURS(time))) + ":" + \
144 String(FORMAT_2_DIGITS(MINS(time))) + ":" + \
145 String(FORMAT_2_DIGITS(SECS(time))) + ":" + \
146 String(FORMAT_3_DIGITS(MILLIS(time))) \
static DateTime * instance
the instance of the class (Singleton)
DateTime(DateTime const &)
Copy constructor of the class.
#define WEB_SERVER
enable the webserver
String getDateStr() const
Returns the current day in a string format.
const String getHTMLData(const int id) const
Since this class is registered as a source of data for the HTML content, it needs return the appropri...
friend String HTML_startDate(const DateTime &dateTime)
Associated function for returing the start day of the device.
~DateTime()
Destructor of the class.
static DateTime * getInstance()
Returns the instance of the class.
String startTime
start time of the system
unsigned long time_t
Referring to the data type unsigned long as time_t.
DateTime()
Constructor of the class.
std::map< int, String(*)(const DateTime &dateTime)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
DateTime & operator=(DateTime const &)
Assignment operator of the class.
friend String HTML_startTime(const DateTime &dateTime)
Associated function for returing the start time of the device.
DS3231 rtc
real-time module
String getDateTimeStr() const
Returns the current datatime in a string format.
String startDate
start day of the system
RTCDateTime getDateTime() const
Returns the current datatime.
String getTimeStr() const
Returns the current time in a string format.