[Exim] Those Darn Timezones - experimental evidence needed

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Philip Hazel
Fecha:  
A: exim-users
Asunto: [Exim] Those Darn Timezones - experimental evidence needed
I've been looking at the problem of ignoring "rougue" values of the TZ
environment variable that happen to be set when Exim is called (see some
previous threads) so as to ensure that the log times are wall clock
times. You might think this kind of thing was standard, but, no...

After some fruitless messing about[*] I think I might have found a simple,
universal, way of doing it, and now I need people (preferably not in the
GMT timezone)[+] to run my test program (below) on as many different OS as
possible. Just compile and run the program (it shouldn't need any fancy
options) and send me the output. Oh, and please run the "date" command as
well, to record your actual local time.

The experiments I've been able to do myself suggest there may be a
problem with SCO systems :-( but other OS seem OK.

Many thanks,
Philip

-------------------------------
[*] including trying to track down tzsetwall() on Solaris, which is in
the man page, but does not seem to actually exist.

[+] I can't do tests on my own local hosts until after March 26th, when
Summer Time begins here

-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.



#include <stdlib.h>
#include <stdio.h>
#include <time.h>

extern char **environ;

static void doit(time_t now, char *s)
{
struct tm *t = localtime(&now);
char *tz = getenv("TZ");
printf("TZ = %s\n", (tz == NULL)? "<unset>" : tz);
printf(" %04d-%02d-%02d %02d:%02d:%02d %s\n",
1900 + t->tm_year, 1 + t->tm_mon, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec, s);
}

int main(void)
{
char *null = NULL;
time_t now = time(NULL);

doit(now, "default");

putenv("TZ=");
tzset();
doit(now, "TZ set to empty string");

putenv("TZ=EST");
tzset();
doit(now, "TZ set to EST");

environ = &null;
tzset();
doit(now, "environment removed");

return 0;
}

/* End */