Bug? WiFi.getTime gives tomorrow

Apologies if this the wrong forum section.

On an MKR1000 and using the WifiRTC example with the only change to this script being the SSID and password...

It shows tomorrow's day.

It appears that the epoch returned from WiFi.getTime() is a day ahead in time.

Today is 13th January 2017, but the example shows it as being the 14th.
Every other aspect of the date and time is correct. Just the day is wrong.

Simplified Sample code:

    unsigned long epoch;
    epoch = WiFi.getTime();
    Serial.print("Epoch received: ");
    Serial.println(epoch);
    rtc.setEpoch(epoch);

    Serial.println();

    Serial.print("Day is ");
    Serial.println(rtc.getDay());

Prints:

Epoch received: 1484395306

Day is 14

Anyone else seeing this problem?

Very strange. In WiFi.cpp there is a line (1005) that says:

tm.tm_mday = systemTime.u8Day + 1;

This should not add 1, because the tm struct for mday is a number from 1 to 31.

Changing it to:
tm.tm_mday = systemTime.u8Day;

Fixes this problem.

There are reports on github of problems with the timestamp but they occurred when the wifi connection was first initiated. Nobody has reported problems with the date being out by one day and I would expect that it would have been noticed very quickly. I can't find a definition of the systemTime structure but I would have assumed that u8Day would indeed already be 1-31 rather than 0-30.
I haven't got a MKR1000 so I can't do any testing of my own.

Pete

Time zone issue?