Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
|
Date and time class. More...
#include <DateTime.h>
Public Member Functions | |
DateTime () | |
Instantiate an uninitialised date and time object. More... | |
DateTime (time_t time) | |
Instantiate a date and time object. More... | |
operator time_t () | |
Get current Unix time. More... | |
void | setTime (time_t time) |
Set time using Unix time. More... | |
void | setTime (int8_t sec, int8_t min, int8_t hour, int8_t day, int8_t month, int16_t year) |
Set time using time and date component values. More... | |
bool | parseHttpDate (String httpDate) |
Parse a HTTP full date and set time and date. More... | |
bool | isNull () |
Check if time date object is initialised. More... | |
time_t | toUnixTime () |
Get Unix time. More... | |
String | toShortDateString () |
Get human readable date. More... | |
String | toShortTimeString (bool includeSeconds=false) |
Get human readable time. More... | |
String | toFullDateTimeString () |
Get human readable date and time. More... | |
String | toISO8601 () |
void | addMilliseconds (long add) |
Add time to date time object. More... | |
Static Public Member Functions | |
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. More... | |
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. More... | |
Public Attributes | |
int8_t | Hour |
Hour (0-23) More... | |
int8_t | Minute |
Minute (0-59) More... | |
int8_t | Second |
Second (0-59) More... | |
int16_t | Milliseconds |
Milliseconds (0-999) More... | |
int8_t | Day |
Day of month (1-31) More... | |
int8_t | DayofWeek |
Day of week (0-6 Sunday is day 0) More... | |
int8_t | Month |
Month (0-11 Jan is month 0) More... | |
int16_t | Year |
Full Year number. More... | |
Date and time class.
Date and time functions mostly work with Unix time, the quantity of seconds since 00:00:00 1970-01-01. There is no support for leap seconds which are added (and in theory, removed) occasionally to compensate for earth rotation variation. This means that timespan calculation and free-running clocks may be inaccurate if they span leap seconds. To facilitate leap seconds, reference must be made to leap second table. This will not be done within the Sming framework and must be handled by application code if required.
DateTime::DateTime | ( | ) |
Instantiate an uninitialised date and time object.
DateTime::DateTime | ( | time_t | time | ) |
Instantiate a date and time object.
time | Unix time to assign to object |
void DateTime::addMilliseconds | ( | long | add | ) |
Add time to date time object.
add | Quantity of milliseconds to add to object |
|
static |
Convert from Unix time to individual time components.
timep | Unix time date value to convert |
psec | Pointer to integer to hold resulting seconds |
pmin | Pointer to integer to hold resulting minutes |
phour | Pointer to integer to hold resulting hour |
pday | Pointer to integer to hold resulting day of month |
pwday | Pointer to integer to hold resulting day of week |
pmonth | Pointer to integer to hold resulting month |
pyear | Pointer to integer to hold resulting year |
|
static |
Convert from individual time components to Unix time.
sec | Seconds |
min | Minutes |
hour | Hours |
day | Days |
month | Month (0-11, Jan=0, Feb=1, ...Dec=11) |
year | Year (1901-2036), either full 4 digit year or 2 digits for 1970-2036 |
bool DateTime::isNull | ( | ) |
Check if time date object is initialised.
True | if object has no value. False if initialised. |
|
inline |
Get current Unix time.
time_t | Quantity of seconds since 00:00:00 1970-01-01 |
bool DateTime::parseHttpDate | ( | String | httpDate | ) |
Parse a HTTP full date and set time and date.
httpDate | HTTP full date in RFC 1123 format, e.g. Sun, 06 Nov 1994 08:49:37 GMT |
bool | True on success |
void DateTime::setTime | ( | time_t | time | ) |
Set time using Unix time.
time | Unix time to set object time to |
void DateTime::setTime | ( | int8_t | sec, |
int8_t | min, | ||
int8_t | hour, | ||
int8_t | day, | ||
int8_t | month, | ||
int16_t | year | ||
) |
Set time using time and date component values.
sec | Seconds |
min | Minutes |
day | Day of month |
month | Month (0=Jan, 11=Dec) |
year | Year |
String DateTime::toFullDateTimeString | ( | ) |
Get human readable date and time.
String | Date and time in format dd.mm.yyyy hh:mm:ss |
String DateTime::toShortDateString | ( | ) |
Get human readable date.
String | Date in requested format, e.g. dd.mm.yyyy |
String DateTime::toShortTimeString | ( | bool | includeSeconds = false | ) |
Get human readable time.
includeSeconds | True to include seconds (Default: false) |
String | Time in format hh:mm or hh:mm:ss |
time_t DateTime::toUnixTime | ( | ) |
Get Unix time.
time_t | Unix time, quantity of seconds since 00:00:00 1970-01-01 |
int8_t DateTime::Day |
Day of month (1-31)
int8_t DateTime::DayofWeek |
Day of week (0-6 Sunday is day 0)
int8_t DateTime::Hour |
Hour (0-23)
int16_t DateTime::Milliseconds |
Milliseconds (0-999)
int8_t DateTime::Minute |
Minute (0-59)
int8_t DateTime::Month |
Month (0-11 Jan is month 0)
int8_t DateTime::Second |
Second (0-59)
int16_t DateTime::Year |
Full Year number.