This SO thread Why does glibc “timezone” global not agree with system time on DST? is not a solution for my problem.
My system has glibc 2.11.3
and for my project I compiled glibc 2.22
. I ran make localedata/install-locales
.
This MCVE displays the correct time only when linked against the old glibc
version. Linking it against the new glibc
version it displays the UTC time:
#include <time.h>
#include <stdio.h>
int main()
{
struct tm * tmNow;
time_t dtNow;
char sBuffer [100];
tzset();
time( &dtNow );
tmNow = localtime( &dtNow );
strftime( sBuffer, sizeof(sBuffer), "%Y-%m-%d %T", tmNow );
printf("%ld - %s\n", timezone, sBuffer);
}
When I try to run tzselect
in the bin/
directory of the new glibc
version I get this error:
./tzselect: line 171: /usr/glibc/share/zoneinfo/iso3166.tab: No such file or directory
./tzselect: time zone files are not set up correctly
More or less it says all but for the moment I am not capable to find out how to set up the file /usr/glibc/share/zoneinfo/iso3166.tab
.
How do I set up the timezone for the new glibc
version permanently?
I do not want to use the TZ variable!
UPDATE:
Using the TZ
variable does not change anything. I guess I did not configure correctly the new glibc
version.
UPDATE: Copying the existing /usr/share/zoneinfo
system directory into the new /usr/glibc/share/zoneinfo
directory at least fixed the problem with the TZ
variable. But as long the TZ
variable is not set the new glibc
version does not recognize the correct timezone.
I opened the new libc.so.6
library with vi
and searched for localtime
.
The hard coded directory where the new glibc
version was looking for localtime
is set to /usr/glibc/etc
.
Then it was an easy task: I ran the command
ln -s /usr/share/zoneinfo/Europe/Vienna /usr/glibc/etc/localtime
and now the localtime
is recognized correctly in the new glibc
version without using the TZ
variable.