add configTime, getLocalTime and support for time in Print

example:
```cpp
//done once on WiFi init
configTime(-7200, 3600, "pool.ntp.org");
//get local time
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
    Serial.println("Failed to obtain time");
    return;
}
//print time
Serial.println(&timeinfo);
//print time with different format
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
```
fixes: https://github.com/espressif/arduino-esp32/issues/29
This commit is contained in:
me-no-dev
2017-01-24 04:07:27 +02:00
parent 6dfbdbca29
commit c8140f8288
4 changed files with 108 additions and 1 deletions

View File

@ -162,6 +162,10 @@ uint16_t makeWord(byte h, byte l);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
extern "C" bool getLocalTime(struct tm * info, uint32_t ms = 5000);
extern "C" void configTime(long gmtOffset_sec, int daylightOffset_sec,
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);
// WMath prototypes
long random(long);
#endif /* __cplusplus */