22 #include "SmingLocale.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)) 114 void setTime(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year)
205 static void fromUnixTime(time_t timep, uint8_t* psec, uint8_t* pmin, uint8_t* phour, uint8_t* pday, uint8_t* pwday,
206 uint8_t* pmonth, uint16_t* pyear);
210 static void fromUnixTime(time_t timep, int8_t* psec, int8_t* pmin, int8_t* phour, int8_t* pday, int8_t* pwday,
211 int8_t* pmonth, int16_t* pyear) SMING_DEPRECATED
213 fromUnixTime(timep, reinterpret_cast<uint8_t*>(psec), reinterpret_cast<uint8_t*>(pmin),
214 reinterpret_cast<uint8_t*>(phour), reinterpret_cast<uint8_t*>(pday),
215 reinterpret_cast<uint8_t*>(pwday), reinterpret_cast<uint8_t*>(pmonth),
216 reinterpret_cast<uint16_t*>(pyear));
238 int8_t* pwday, int8_t* pmonth, int16_t* pyear) SMING_DEPRECATED
240 fromUnixTime(timep, reinterpret_cast<uint8_t*>(psec), reinterpret_cast<uint8_t*>(pmin),
241 reinterpret_cast<uint8_t*>(phour), reinterpret_cast<uint8_t*>(pday),
242 reinterpret_cast<uint8_t*>(pwday), reinterpret_cast<uint8_t*>(pmonth),
243 reinterpret_cast<uint16_t*>(pyear));
258 static time_t
toUnixTime(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year);
273 static time_t
convertToUnixTime(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month,
274 uint16_t year) SMING_DEPRECATED
276 return toUnixTime(sec, min, hour, day, month, year);
331 return format(formatString.c_str());
335 void calcDayOfYear();
336 uint8_t calcWeek(uint8_t firstDay);
Thursday.
Definition: DateTime.h:64
Date and time class.
Definition: DateTime.h:77
static void fromUnixTime(time_t timep, int8_t *psec, int8_t *pmin, int8_t *phour, int8_t *pday, int8_t *pwday, int8_t *pmonth, int16_t *pyear) SMING_DEPRECATED
Definition: DateTime.h:210
dtDays_t
Days of week.
Definition: DateTime.h:59
String toISO8601()
Get human readable date and time.
DateTime()
Instantiate an uninitialised date and time object.
Definition: DateTime.h:82
uint16_t Year
Full Year number.
Definition: DateTime.h:347
DateTime(time_t time)
Instantiate a date and time object from a Unix timestamp.
Definition: DateTime.h:89
time_t toUnixTime()
Get Unix time.
bool parseHttpDate(const String &httpDate) SMING_DEPRECATED
Parse a HTTP full date and set time and date.
Definition: DateTime.h:141
uint16_t DayofYear
Day of year (0-365)
Definition: DateTime.h:345
The string class.
Definition: WString.h:104
Wednesday.
Definition: DateTime.h:63
uint8_t DayofWeek
Day of week (0-6 Sunday is day 0)
Definition: DateTime.h:344
Saturday.
Definition: DateTime.h:66
uint8_t Minute
Minute (0-59)
Definition: DateTime.h:340
String toShortTimeString(bool includeSeconds=false)
Get human readable time.
void setTime(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year)
Set time using time and date component values.
Definition: DateTime.h:114
uint8_t Day
Day of month (1-31)
Definition: DateTime.h:343
String toFullDateTimeString()
Get human readable date and time.
Sunday.
Definition: DateTime.h:60
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) SMING_DEPRECATED
Convert from Unix time to individual time components.
Definition: DateTime.h:237
static time_t convertToUnixTime(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year) SMING_DEPRECATED
Convert from individual time components to Unix time.
Definition: DateTime.h:273
String toShortDateString()
Get human readable date.
Tuesday.
Definition: DateTime.h:62
uint8_t Month
Month (0-11 Jan is month 0)
Definition: DateTime.h:346
void addMilliseconds(long add)
Add time to date time object.
uint16_t Milliseconds
Milliseconds (0-999)
Definition: DateTime.h:342
String format(const String &formatString)
Create string formatted with time and date placeholders.
Definition: DateTime.h:329
uint8_t Second
Second (0-59)
Definition: DateTime.h:341
uint8_t Hour
Hour (0-23)
Definition: DateTime.h:339
void setTime(time_t time)
Set time using Unix timestamp.
Monday.
Definition: DateTime.h:61
static void fromUnixTime(time_t timep, uint8_t *psec, uint8_t *pmin, uint8_t *phour, uint8_t *pday, uint8_t *pwday, uint8_t *pmonth, uint16_t *pyear)
Convert from Unix time to individual time components.
Friday.
Definition: DateTime.h:65
bool isNull()
Check if time date object is initialised.
String toHTTPDate()
Get human readable date and time.
bool fromHttpDate(const String &httpDate)
Parse a HTTP full date and set time and date.
String format(const char *formatString)
Create string formatted with time and date placeholders.