[Info-vax] how to get the time of any timezone (C or VMS RTL/system services/etc.)
Jim
mckinneyj at saic.com
Mon May 2 13:19:14 EDT 2011
On May 2, 11:59 am, Pierre <pierre.... at gmail.com> wrote:
> hi,
>
> for historical reasons, my machine time is UTC [I can not change
> this].
> is it possible using C or VMS RTL/system services/etc. to get the
> "local time" (the one of my wall clock) ?
> as all the logicals point to UTC, I must be able to specify the
> requested timezone... :-/
>
> I'm running VMS 7.3-2, 8.3, 8.4
>
> TIA, Pierre
Perhaps the example below will help...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main (int argc, char *argv[])
{
time_t t;
typedef struct tm tm_t;
tm_t *tml;
tm_t *tmr;
setenv ("TZ", "US/EASTERN", 1);
tzset();
t = time((time_t)0);
tml = calloc( sizeof(tm_t), 1 );
tmr = localtime_r(&t,tml);
printf("US/EASTERN: %d-%02d-%02d-%02d:%02d:%02d.%03d\n",
tml->tm_year+1900, tml->tm_mon+1, tml->tm_mday,
tml->tm_hour, tml->tm_min, tml->tm_sec,
(0));
free(tml);
setenv ("TZ", "JAPAN", 1);
tzset();
t = time((time_t)0);
tml = calloc( sizeof(tm_t), 1 );
tmr = localtime_r(&t,tml);
printf("Japan: %d-%02d-%02d-%02d:%02d:%02d.%03d\n",
tml->tm_year+1900, tml->tm_mon+1, tml->tm_mday,
tml->tm_hour, tml->tm_min, tml->tm_sec,
(0));
free(tml);
}
More information about the Info-vax
mailing list