Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: Mark Garrett <Mark.Garrett@wedontwantyourspam.com.au>
Subject: Re: Convert local time to gmt time without using TimeZone Env variable
Date: Sun, 08 Apr 2001 23:41:00 GMT	[thread overview]
Message-ID: <B6F732E9.16306%Mark.Garrett@wedontwantyourspam.com.au> (raw)
In-Reply-To: 3ACD8EF9.221E5F8F@opteway.com

in article 3ACD8EF9.221E5F8F@opteway.com, francois reygagne at
freygagne@opteway.com wrote on 06/04/2001 19:40:

> The ftcs unix mktime use the function tzset to initialize time
> conversion information by setting an environment variable. That is not
> thread-safe.
> 
> As I want to work in multi_threaded design with different time-zone, one
> 
> per each thread, I can't use the unix standard fonctions like mktime. I
> need a thread-safe function that converts a local-time attached to its
> timezone into a GMT time as follow:
> 
> void localtime_to_gmt(const char * timezone,  const struct tm
> localtime,  time_t * gmt_time);
> 
> Is there a  sofftware which uses instead of TZ env variable a local time
> 
> zone variable attached to the process to convert a local time to GMT ?
> 

You have always got tm_gmoff to work any tm structure back to GMT and you
can call gmtime_r eg.

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

main()
{
        time_t lt;
        struct tm       gmt;


        lt = time((time_t *) NULL);
        gmtime_r(&lt, &gmt);
}

RTFM

    Cheers
        Mark ;)



      reply	other threads:[~2001-04-08 23:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-06  9:40 Convert local time to gmt time without using TimeZone Env variable francois reygagne
2001-04-08 23:41 ` Mark Garrett [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox