@tboeckel
Okay I made some experiment, consider the following sample
#include <stdio.h>
#include <time.h>
#include <locale.h>
int main(void)
{
time_t now = time(NULL);
char localstr[2048], gmtstr[2048];
struct tm localtm, gmtm;
setlocale(LC_ALL, "fr");
localtime_r(&now, &localtm);
gmtime_r(&now, &gmtm);
strftime(localstr, 2040, "%A %e %B %Y %X, (%Z %z)", &localtm);
strftime(gmtstr, 2040, "%A %e %B %Y %X, (%Z %z)", &gmtm);
printf("localtime : %s (tm offset %ld)\n"
"utc : %s (tm offset %ld)\n",
localstr, localtm.tm_gmtoff, gmtstr, gmtm.tm_gmtoff);
return 0;
}
now this output
Nouvelle t?che Shell 11
11.Langages:tempo> date
Vendredi 21/08/2009 11h10
11.Langages:tempo> testime
localtime : Friday 21 August 2009 11:10:35, (CET +0200) (tm offset -120)
utc : Friday 21 August 2009 09:10:35, (CEST +0200) (tm offset 0)
Now I'm not an expert of ANSI locale and timezone but in this small sample there things that annoy me :
1) strftime on the localtime give a timezone (%Z) of CET while we are currently at CEST and the offset (%z) and tm_gmtoff are correctly set to 2 hours
2) despite I used %A and %B to get locale's name for weekday and month I got english one no matter if I use setlocale() or not and whatever value I put for it (looking at the specs on opengroup.org it passing an empty string should have used the default system's locale)
3) strange (but opengroup.org says the result is undefined) strftime returns the correct timezone (CEST) when passed an UTC time...