My embedded Linux program needs to convert UTC time to local time for a report saved in a text file. The most obvious way to do this is to use the API function strftime().
However... on my system, the following code does not work during Daylight Saving time - the resultant time is off by an hour:
char dateTimeOut[128] = { 0 };
bool isError = false;
struct tm timeValue = { 0 };
do {
if (0 > mktime(&timeValue)) { isError = true; break; }
isError = 0 == strftime(&dateTimeOut[0], sizeof(dateTimeOut), "%a %d %b %Y %T", &timeValue);
} while (false);
My embedded platform is a Linux (ARM/busybox) system. It has systemd and the timedatectl system executable, but it does not have /etc/timezone, /usr/share/zoneinfo/, nor the zic timezone data compiler program.
I have plenty of system disk space on this embedded system.
Is it possible to copy the /usr/share/zoneinfo contents from an amd64 Linux implementation to my embedded ARM Linux implementation "as-is" to get access to the timezone functionality that timedatectl and strftime() provide?
I ended up creating a tarball of /usr/share/zoneinfo/ from an Ubuntu system, copied it and unzipped it on the embedded system, and the following "just worked."
So it seems the /usr/share/zoneinfo is platform agnostic.