TZ=utc00
timezone offset:0
tzname[0]:utc tzname[1]=
This was the output of the program.
when i tried doing the same thing in my application, it says the TZ not
set.
The application consists of 2 tasks. say appmgr and log.
appmgr spawns log. log task logs to file the time and date from cmtime()
output.
The problem is that the file which the log task logs is different from the
date output by 5 hrs.
If logtask is run log seperately, then there is no issue. But if appmgr is
run then this problem occurs. Tried putting the below code in log.cc file.
It prints TZ not set.
But if appmgr passes the environment as a parameter to this task then it
is working fine.
What you said on context of process applies here appropriately.
SO, conclusion is that TZ is context dependent.and need to be set on a per
process basis. Am i right?
One more problem when the below program is being spwaned by appmgr it says
TZ not set , but when run seperately its fine.DOn’t know what is this
issue, now!
Thanks
Tried included the below statements in log.c program. looks like when
appmgr spawns log , it prints TZ not set and when log is run seperately it
logs. when explicitly TZ ebvironment is set using setenv,
Eric Johnson wrote:
TZ is just an ordinary environment variable, and is no more persistent than
any other environment variable (i.e. not). There is nothing special about it
at all. The interpretation of current system time thus varies on a process
by process basis depending on the setting of the TZ environment variable
within the context of that process.
I suspect your TZ is not what you think it is in the application. If
TZ=UTC00 is present in the application’s environment, the time zone name
would be UTC not EST EDT. How are you testing TZ?
/* timeprog.c
Build this program and from the shell, compare:
env TZ=UTC0 timeprog
env TZ=EST5EDT4 timeprog
(unset TZ && timeprog)
*/
#include <stdlib.h
#include <stdio.h
#include <time.h
main()
{
char *p;
time_t t;
struct tm *mytm;
if (p=getenv(“TZ”))
printf(“TZ=%sn”,p);
else
printf(“TZ not setn”);
tzset();
printf(“timezone offset=%dn”,timezone);
printf(“tzname[0]=%s tzname[1]=%sn”,tzname[0],tzname[1]);
}
“radha krishnan” <> radha.nk@geind.ge.com> > wrote in message
news:d0m4e4$rbk$> 1@inn.qnx.com> …
While printing the TZ in application, it says
TZ:UTC00
daylight:1
timezone:18000
time zone names:EST EDT
Here we can see that environment variable TZ is set to UTC, but still the
timezone names are reflecting the EST.
Also, tested that this needs to be set whenever application is run. Is
there a permanent setting?
why this setting in application need to be done? aprt from environment TZ?
Eric Johnson wrote:
Setting TZ in your sysinit won’t guarantee TZ is set for your
application.
If TZ is not set, on QNX 4 the Watcom library defaulted to Eastern
Standard
Time so that would explain the discrepancy. Check the value of TZ in the
program that is using the API and track back from there. If you program
runs
for any period of time you can do this easily from another shell by
running
‘sin env’ as root. That will be nice also as it will show you the
environment of the parent process etc. It may be immediately obvious
what’s
wrong.
“radha krishnan” <> radha.nk@geind.ge.com> > wrote in message
news:d0jh06$qre$> 1@inn.qnx.com> …
QNX4:
In my PC, we have a TZ setting UTC00.rtc hw in sysinit file.
But when we used time() and ctime() API to log the current date and
time,
we see a 4-5 hours difference between times in file and date utility
output.
But when we had TZ setting as est, the date and time logged to file
were
matching with the same API.
We tried with TZ=UTC00,and used gmtime() ,time() API to log the GMT
time?
Are we missing something?
\