🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #6332

BC++ time related Global Variables

#6332
From: Michael Alan Corn
Date: Tue, 17 Nov 1992 15:57
58 lines
2316 bytes
      
      This is probably too simply for you C/C++ gurus out there, but how does
one set the global variables for timezone and day light savings in BC++?
The following doesn't work:
misc includes
extern long timezone;
extern int  daylight;
long getuservalue(void);

main()
{
time_t t;
struct tm *gmt;
timezone = getuservalue();
daylight = 1;                 //default is 0;
t = time(NULL);
localtime(&t);
gmt = gmtime(&t);
printf("GMT is:    %s",asctime(gmt));
return 0;
}

No matter what value is entered for timezone, the gmt value doesn't change. 
Since the gmt is a function of localtime, timezone, and daylight, it should
change. If the above code (with appropriate #includes) is run, the gmt
computed is the same regardless of the value timezone is set to, or the value
of daylight.  Using the tzset alternative has little value as well:

main()
{
time_t t;
struct tm *gmt1, *gmt2;
char *tzstr1 = "TZ=PST8";
char *tzstr2 = "TZ=PST8PDT";
putenv(tzstr1);
tzset();
t = time(NULL);
localtime(&t);
gmt1 = gmtime(&t);
putenv(tzstr2);
tzset();
t = time(NULL);
localtime(&t);
gmt2 = gmtime(&t);
printf("gmt1 = %s, gmt2 = %s",asctime(gmt1),asctime(gmt2));
return 0;
}

I've yet to get the gmt, or any other time function to respond differently by
any setting of the "TZ" variable, save for the middle number.  So if someone
could please explain, either what I'm doing wrong,( I'd like to have the user
enter the difference between gmt and local time, and whether daylight savings
is in effect, and set the appropriate values myself), or confirm something is
amiss, I would be greatly indebted.  I wouldn't even complain if Borland
responded, since I've already spent 90 min. on hold over the last week and
have given up on tech support. Post or email to macg9505@uxa.cso.uiuc.edu 
Thanks in advance.  Mike
Technical Details
Message-ID: <BxvAzo.2My@news.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!macg9505

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!macg9505
From: macg9505@uxa.cso.uiuc.edu (Michael Alan Corn)
Newsgroups: comp.os.msdos.programmer
Subject: BC++ time related Global Variables
Message-ID: <BxvAzo.2My@news.cso.uiuc.edu>
Date: 17 Nov 92 15:57:20 GMT
Article-I.D.: news.BxvAzo.2My
Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
Organization: University of Illinois at Urbana
Lines: 58