mbed_localtime: Add support of wday.

This field is necessary, it is used by several vendor RTC: Atmel, ST, NUVOTON,
NXP.
pull/4499/head
Vincent Coubard 2017-06-08 10:11:01 +01:00
parent 946ed353bc
commit 01f1e08358
2 changed files with 6 additions and 0 deletions

View File

@ -123,6 +123,11 @@ bool _rtc_localtime(time_t timestamp, struct tm* time_info) {
time_info->tm_hour = timestamp % 24;
timestamp = timestamp / 24; // timestamp in days;
// compute the weekday
// The 1st of January 1970 was a Thursday which is equal to 4 in the weekday
// representation ranging from [0:6]
time_info->tm_wday = (timestamp + 4) % 7;
// years start at 70
time_info->tm_year = 70;
while (true) {

View File

@ -80,6 +80,7 @@ time_t _rtc_mktime(const struct tm* calendar_time);
* - tm_mday
* - tm_mon
* - tm_year
* - tm_wday
* The object remains untouched if the time in input is invalid.
* @return true if the conversion was successful, false otherwise.
*