Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!orstcs!neptune!pvo3366 From: pvo3366@neptune.uucp (Paul O'Neill) Newsgroups: comp.unix.questions Subject: UNIX time and the parent environment Summary: manipulations of TZ don't affect timelocal() Keywords: timelocal() putenv() getenv() TZ time_t tm Message-ID: <12269@orstcs.CS.ORST.EDU> Date: 28 Aug 89 23:55:40 GMT Reply-To: pvo3366@oce.orst.edu (Paul O'Neill) Organization: College of Oceanography, Oregon State Univ., Corvallis, Or. Lines: 53 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@oce.orst.edu Coastal Imaging Lab OSU--Oceanography Corvallis, OR 97331 503-754-3251