UNIX time and the parent environment

Paul O'Neill pvo3366 at neptune.uucp
Tue Aug 29 09:55:40 AEST 1989


I am digitizing video tapes with an image processor in a Sun 4/110, SunOS 4.0.1.

In the header to the time series that I'm producing I want to have the following
2 numbers:

	data_start_time = number of seconds since Jan. 1, 1970, 00:00, GMT
			  (when the video started)

	dgtz_start_time = number of seconds since Jan. 1, 1970, 00:00, GMT
			  (when the digitizing started)

It's easy enough for the digitizing program to prompt the user for enough
data to fill in a skeleton struct tm.  timelocal(3) then seems to be the
way to go to get the time_t (# of seconds since ....).

THE PROBLEM:  The tapes are usually recorded in a different time zone than
	      they are digitized in.

Nominally timelocal(3) grabs the local time zone for the conversion 
-- this works.

If environmental variable TZ is set to a valid zoneinfo path (something in 
/usr/share/lib/zoneinfo), timelocal(3) grabs this time zone for the 
conversion -- this works.

If TZ exists, but is unset, timelocal(3) converts as if time zone = GMT
-- this works.

But I need to do 2 timelocal(3) calls in the same program, each with a 
different time zone.

I can successfully call getenv(3) and manipulate what's at the returned 
address.  I can also successfully call putenv(3) and set TZ that way.  But
timelocal(3) doesn't pay any attention to the environment I've manipulated in
this way.  It insists on using the parent shell's idea of TZ.

Manually filling in the struct tm's .tm_zone and .tm_gmtoff doesn't work either,
because timelocal(3) overwrites them during the call with what it thinks
they should be to match the parent's TZ.

THE QUESTION: Why doesn't timelocal() use the environmental variable I'm
manipulating?  Is there a way to get it to sit up and take notice?  How do 
I do multiple yr/mo/da/hr/min/sec -> time_since_the_epoch conversions in 
multiple time zones?

Thanks. (This is driving me nuts!)


Paul O'Neill                 pvo at oce.orst.edu
Coastal Imaging Lab
OSU--Oceanography
Corvallis, OR  97331         503-754-3251



More information about the Comp.unix.questions mailing list