20 #include <user_config.h> 22 #include "../../Wiring/WString.h" 26 #define SECS_PER_MIN (60UL) 27 #define SECS_PER_HOUR (3600UL) 28 #define SECS_PER_DAY (SECS_PER_HOUR * 24L) 29 #define DAYS_PER_WEEK (7L) 30 #define SECS_PER_WEEK (SECS_PER_DAY * DAYS_PER_WEEK) 31 #define SECS_PER_YEAR (SECS_PER_WEEK * 52L) 32 #define SECS_YR_2000 (946681200UL) 36 #define numberOfSeconds(_time_) (_time_ % SECS_PER_MIN) 38 #define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN) 40 #define numberOfHours(_time_) (( _time_% SECS_PER_DAY) / SECS_PER_HOUR) 42 #define dayOfWeek(_time_) (( _time_ / SECS_PER_DAY + 4) % DAYS_PER_WEEK) // 0 = Sunday 44 #define elapsedDays(_time_) ( _time_ / SECS_PER_DAY) // this is number of days since Jan 1 1970 46 #define elapsedSecsToday(_time_) (_time_ % SECS_PER_DAY) // the number of seconds since last midnight 48 #define previousMidnight(_time_) (( _time_ / SECS_PER_DAY) * SECS_PER_DAY) // time at the start of the given day 50 #define nextMidnight(_time_) ( previousMidnight(_time_) + SECS_PER_DAY ) // time at the end of the given day 52 #define elapsedSecsThisWeek(_time_) (elapsedSecsToday(_time_) + (dayOfWeek(_time_) * SECS_PER_DAY) ) 106 void setTime(int8_t sec, int8_t min, int8_t hour, int8_t day, int8_t month, int16_t year);
165 static void convertFromUnixTime(time_t timep, int8_t *psec, int8_t *pmin, int8_t *phour, int8_t *pday, int8_t *pwday, int8_t *pmonth, int16_t *pyear);
179 static time_t
convertToUnixTime(int8_t sec, int8_t min, int8_t hour, int8_t day, int8_t month, int16_t year);
Thursday.
Definition: DateTime.h:64
Date and time class.
Definition: DateTime.h:77
dtDays_t
Days of week.
Definition: DateTime.h:59
DateTime()
Instantiate an uninitialised date and time object.
time_t toUnixTime()
Get Unix time.
int8_t Day
Day of month (1-31)
Definition: DateTime.h:186
Wednesday.
Definition: DateTime.h:63
Saturday.
Definition: DateTime.h:66
int8_t Hour
Hour (0-23)
Definition: DateTime.h:182
String toShortTimeString(bool includeSeconds=false)
Get human readable time.
int8_t Month
Month (0-11 Jan is month 0)
Definition: DateTime.h:188
int8_t DayofWeek
Day of week (0-6 Sunday is day 0)
Definition: DateTime.h:187
String toFullDateTimeString()
Get human readable date and time.
int16_t Milliseconds
Milliseconds (0-999)
Definition: DateTime.h:185
int8_t Minute
Minute (0-59)
Definition: DateTime.h:183
Sunday.
Definition: DateTime.h:60
String toShortDateString()
Get human readable date.
Tuesday.
Definition: DateTime.h:62
void addMilliseconds(long add)
Add time to date time object.
static time_t convertToUnixTime(int8_t sec, int8_t min, int8_t hour, int8_t day, int8_t month, int16_t year)
Convert from individual time components to Unix time.
bool parseHttpDate(String httpDate)
Parse a HTTP full date and set time and date.
static void convertFromUnixTime(time_t timep, int8_t *psec, int8_t *pmin, int8_t *phour, int8_t *pday, int8_t *pwday, int8_t *pmonth, int16_t *pyear)
Convert from Unix time to individual time components.
int8_t Second
Second (0-59)
Definition: DateTime.h:184
void setTime(time_t time)
Set time using Unix time.
Monday.
Definition: DateTime.h:61
Friday.
Definition: DateTime.h:65
int16_t Year
Full Year number.
Definition: DateTime.h:189
bool isNull()
Check if time date object is initialised.