| > We (PATHWORKS) have a lot of code from Unix that uses globals
> "timezone" and "daylight".
>
> We simulate these on V7 by assigning them the values of decc$gl_xxx on
> startup.
>
Why to simulate? The "timezone" and "daylight" global variables are set
on both VMS and Unix by the tzset() function.
On both systems, the daylight variable does not indicate whether the current
local time is a Daylight Saving Time or not. The meaning of daylight variable
is as follows:
(from description of the tzset() function in the DEC C RTL Reference Manual,
or from tzset man pages):
extern int daylight;
. daylight is set to 0 if Daylight Savings Time should never be applied to
^^^^^^^^^^^^^^^^^^^^^^^^^^
the time zone. Otherwise, daylight is set to 1.
^^^^^^^^^^^^^
Boris
|
| Just to show, how it works.
Note, that the following variables:
extern long int timezone;
extern int daylight;
extern char *tzname[];
present a *supported* way to get information about the time zone in use.
The *current* DST indicator and the name of the *current* time zone (which
can be either STD or DST zone name) is returned by the localtime() function
in tm_isdst and tm_zone members of the tm structure passed, respectively.
Boris
$ say f$getsyi("version")
V7.1
$ run x
Before tzset():
decc$gl_daylight: 0
daylight: 0
decc$gl_timezone: 0
timezone: 0
tzname[0]: (null) (null)
After tzset():
decc$gl_daylight: 1
daylight: 1
decc$gl_timezone: -7200
timezone: -7200
tzname[0]: IST IDT
tm_ptr->tm_isdst: 0
tm_ptr->tm_zone: IST
X.C
===
#include <stdio.h>
#include <time.h>
extern int decc$gl_daylight;
extern long int decc$gl_timezone;
extern long int timezone;
extern int daylight;
extern char *tzname[];
main()
{
time_t bintim;
struct tm *tm_ptr;
printf("\nBefore tzset():\n\n");
printf("decc$gl_daylight: %d\n", decc$gl_daylight);
printf("daylight: %d\n", daylight);
printf("decc$gl_timezone: %d\n", decc$gl_timezone);
printf("timezone: %d\n", timezone);
printf("tzname[0]: %s %s\n", tzname[0], tzname[1]);
tzset();
printf("\nAfter tzset():\n\n");
printf("decc$gl_daylight: %d\n", decc$gl_daylight);
printf("daylight: %d\n", daylight);
printf("decc$gl_timezone: %d\n", decc$gl_timezone);
printf("timezone: %d\n", timezone);
printf("tzname[0]: %s %s\n", tzname[0], tzname[1]);
bintim = time(NULL);
tm_ptr = localtime(&bintim);
printf("\ntm_ptr->tm_isdst: %d\n", tm_ptr->tm_isdst);
printf("tm_ptr->tm_zone: %s\n", tm_ptr->tm_zone);
}
|