Time(0) is wrong until after an app sync

My Una Watch is set to BST. Calling time(0) in my Glance sometimes gets the wrong time.

I’m writing an app which uses the Unix Epoch for time:

const std::time_t t = std::time(0);

I restarted my Una Watch and opened the Glance. That showed 1790633146, which was an hour ahead of the real time 1790629546.

I opened the Una Android app, let it sync, then opened my Glance again. It showed the correct time.

Is this expected behaviour? If so, is there a way to always get the correct Epoch time for UTC?

(It has been nearly 30 years since I last did C++ in anger. Please feel free to tell me I’m missing something obvious!)

Hi @edent, I tried to reproduce this on my side and couldn’t, which might at least help narrow it down.

On firmware 1.5.0 I restarted the watch with the phone’s Bluetooth off, and opened two of my apps before any sync. Both read std::time(nullptr) and convert from UTC, so the same call as your time(0). The time was right before the sync and still right after it. I ran it twice: once with the phone’s timezone as I normally have it, and once with the phone set to London so the watch was on BST like yours. No hour difference either way.

The thing that stood out in your numbers is that the gap is exactly 3600 seconds, which is BST’s daylight-saving hour, so my first guess was the watch losing DST across a restart. The London run didn’t show it though. The two differences I can see between your setup and mine are that yours is a Glance and mine were apps, and possibly the firmware. Which version are you on?

If it’s useful, I can put together a tiny Glance that shows the raw time(0) next to UTC and local time, so we’d both be looking at the same thing.