Convert local time to gmt time without using TZ Env variable
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); The right way to do that is to change TZ, but that is not thread-safe Is it feasible to recode (public-domain) Olson timezone sources to use an explicit state parameter rather than relying on global variables ? Is there a free software portable to Linux RedHat, OSF Tru64, HP_UX and Sun Solaris 5.8 using olson tzdata which can do that ? Is there someone who knows the design or have a design document relative to olson software to help me. 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 -- 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
<<On Wed, 11 Apr 2001 23:50:34 +0200, francois reygagne <freygagne@opteway.com> said:
The right way to do that is to change TZ, but that is not thread-safe
Well, yes and no. It may be possible to update the timezone code to use thread-specific data to store its representation of the ``current timezone''. I suspect that this would be the easiest (in terms of code needing to be modified) way to provide a thread-safe timezone setting. -GAWollman
participants (2)
-
francois reygagne -
Garrett Wollman