Hi,
I have an arbitrary date/time within an arbitrary timezone
and I want to convert this to UTC (or localtime). How do I do this?
I know about getdate(3C), but this doesn't work, if
the TZ variable is not the same as the one in the date/time
I provide. This is on Solaris 2.5.1/2.6.
#include <stdio.h>Quote:> echo $TZ
MET
> cat test.c
#include <stdlib.h>
#include <time.h>
int main(void) {
struct tm *timePointer;
struct tm time1, time2;
putenv("DATEMSK=/tmp/getdatemask");
timePointer = getdate("24 9 1968 12:34 CET");
if (NULL == timePointer) {
printf("Oops, getdate test error <%d>\n", getdate_err);
return 1;
}
return 0;
Oops, getdate test error <7>Quote:}
> cat /tmp/getdatemask
%d %m %Y %H:%M %Z
> cc time.c ; ./a.out
Exit 1
Change the timezone CET in the program to MET and the program
works just fine.
I know that I could change TZ before the invocation of getdate(),
but I need this in a multithreaded program, and thus I'd have to
synchronize access to all time/date-processing functions, which is
a lot of work.
Guenther
P.S.: I'd be happy, if I just could find out, what the time difference
between any given time in a timezone and UTC was.