* Convert local time to gmt time without using TimeZone Env variable
@ 2001-04-06 9:40 francois reygagne
2001-04-08 23:41 ` Mark Garrett
0 siblings, 1 reply; 2+ messages in thread
From: francois reygagne @ 2001-04-06 9:40 UTC (permalink / raw)
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 ?
Thanks for your help ?
Fran�ois REYGAGNE. Software Architect.
opt[e]way S.A., 2881 route des Cr�tes, BP308
06906 Sophia Antipolis Cedex, FRANCE
t�l: +33 (0)4 92 95 27 01 http://www.opteway.com
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Convert local time to gmt time without using TimeZone Env variable
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
0 siblings, 0 replies; 2+ messages in thread
From: Mark Garrett @ 2001-04-08 23:41 UTC (permalink / raw)
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(<, &gmt);
}
RTFM
Cheers
Mark ;)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-04-08 23:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox