Electronics > Microcontrollers
How to deal with timezones/DST on portable devices?
cubeflake:
We are developing a portable device that stores files on an SD card (FAT32 for now, but maybe exFAT in the future). When the device is manufactured, we program it with the current time which is then stored in an RTC.
We only recently realized that this might cause issues when it comes to timestamps. FAT32 has no notion of timezone, exFAT does, but even then we have no way of knowing in which timezone a device is.
That means that the stored timestamps of the files will only be correct if our customer happens to live in the same timezone as us.
We could maybe ask our customer to set the correct timezone via the USB interface or something like that, but that could be annoying for our customers
Does anyone know how other devices such as field recorders, camera's etc deal with this issue?
eutectique:
--- Quote from: cubeflake on November 06, 2024, 01:54:57 pm ---We are developing a portable device that stores files on an SD card (FAT32 for now, but maybe exFAT in the future). When the device is manufactured, we program it with the current time which is then stored in an RTC.
--- End quote ---
If the time is not visible to the client, then set it to UTC.
--- Quote from: cubeflake on November 06, 2024, 01:54:57 pm ---but even then we have no way of knowing in which timezone a device is.
--- End quote ---
Why is it important in the first place?
--- Quote from: cubeflake on November 06, 2024, 01:54:57 pm ---Does anyone know how other devices such as field recorders, camera's etc deal with this issue?
--- End quote ---
All the cameras that I've had never had this issue. Just set the date/time in the UI and live with it. No time zones, no DST.
asmi:
Non-connected devices typically let user set date and time, and use it for timestamping.
nctnico:
There are libraries for this purpose but these are not small as these need to implement daylight savings as well. But it is doable.
Without such libraries there are two options: timestamp in UTC or let the user set whatever time they like (with the requirement to adjust when the daylight savings change). The advantage of using UTC is that you'll have a monotonic timestamp you can always relate back to local time which can help to interpret log files (especially when dealing with a sequence of events spanning hours or even days). The advantage of having a local time is that the users can relate events to their own time.
NorthGuy:
What is important is the time zone which you have used to set RTC, not where the customer is located.
RTC will wander away from real time eventually anyway.
Navigation
[0] Message Index
[#] Next page
Go to full version