Time Conversoin Question [forwarded with permission]

Arthur David Olson ado
Mon Mar 21 14:50:36 UTC 1994


> From aaron at lehman.com Thu Mar 17 16:49:11 1994
> Return-Path: <aaron at lehman.com>
> Received: from lehman.com by elsie.nci.nih.gov (4.1/SMI-4.1)
> 	id AA28619; Thu, 17 Mar 94 16:49:08 EST
> Received: from relay.lehman.com by lehman.com (8.6.4/LB 0.1)
> 	id QAA19119; Thu, 17 Mar 1994 16:48:58 -0500
> Received: from killer.lehman.com by relay.lehman.com (4.1/LB-0.6)
> 	id AA04769; Thu, 17 Mar 94 16:48:51 EST
> Received: from yen.lehman.com by killer.lehman.com (5.0/SMI-SVR4)
> 	id AA29096; Thu, 17 Mar 1994 16:48:48 +0500
> Date: Thu, 17 Mar 1994 16:48:48 +0500
> From: aaron at lehman.com (Aaron Akman)
> Message-Id: <9403172148.AA29096 at killer.lehman.com>
> Received: by yen.lehman.com (4.1/SMI-4.1)
> 	id AA03187; Thu, 17 Mar 94 16:48:45 EST
> To: ado at elsie.nci.nih.gov
> Subject: Time Conversion Question
> Content-Length: 1037
> Status: RO
> 
> Arthur,
> 
> I've downloaded your timezone stuff (got pointers from Arnold Robbins
> and Don Libes), and have a question:
> 
> I'm looking to convert from GMT to one of a few timezones, or from one
> timezone to another.  I'm concerned about setting TZ and calling
> tzset() because I think it changes some global state associated with
> the process.  If I were interrupted before setting TZ back and
> re-calling tzset(), I could have an interrupt function that doesn't
> have the right local TZ setting.  I.e.
> 
> get_other_local_time(char* tzsetting)
> {
> 	oldsetting = temporarily_set_TZ(tzsetting);
> 	tzset();
> 
> 	do_time_stuff_with_alternate_TZ();
> 
> 	/* i could get interrupted here by a signal handler
> 	   that needs the real local time!! */
> 
> 	set_TZ_back(oldsetting);
> 	tzset();
> }
> 
> Is there a better way?  Is it true the effect of tzset() global?  I
> haven't gone through the .c files in depth yet.  
> 
> It seems like this should be a common problem for a globally
> distributed system.
> 
> Thanks in advance for any advice,
> Aaron Akman
> aaron at lehman.com
> 212 464 3978



More information about the tz mailing list