C library source for tzset? - Programmer
This is a discussion on C library source for tzset? - Programmer ; In KB article 39908 ( http://support.microsoft.com/kb/39908 ) Microsoft
says to correct the DST problem by obtaining the "run-time library
source code available for the time functions..." This refers to 16-bit
products from MSC5.1 through VC1.5. Where does one obtain these ...
-
C library source for tzset?
In KB article 39908 (http://support.microsoft.com/kb/39908) Microsoft
says to correct the DST problem by obtaining the "run-time library
source code available for the time functions..." This refers to 16-bit
products from MSC5.1 through VC1.5. Where does one obtain these sources?
They did not come originally with the products (only startup source was
supplied) and the oldest I could find for download was VC20. I particularly
need MSC6.0a, but VC1.5[2] would be good as well.
Dan Lanciani
ddl@danlan.*com
-
Re: C library source for tzset?
Hi,
I tried to send email to the address you gave (minus the *), but it bounced.
Here is your source, from the MSC 6.0 RTL
-----------------------------------------------
/***
*tzset.c - set timezone information and see if we're in daylight time
*
* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines tzset() - set timezone and daylight saving time vars
*
************************************************** *****************************/
#include
#include
#include
#include
#include
#include
#include
/***
*void tzset() - sets timezone information and calc if in daylight time
*
*Purpose:
* Sets the timezone information from the TZ environment variable
* and then sets timezone, daylight, and tzname. If we're in daylight
* time is automatically calculated.
*
*Entry:
* None, reads TZ environment variable.
*
*Exit:
* sets daylight, timezone, and tzname global vars, no return value
*
*Exceptions:
*
************************************************** *****************************/
#define _tzset_lk tzset
void __tzset()
{
static int near first_time;
_mlock( _TIME_LOCK );
if ( ! first_time )
{
_tzset_lk();
first_time++;
}
_munlock( _TIME_LOCK );
}
void tzset()
{
REG1 char *TZ;
REG2 int i;
if (!(TZ = getenv("TZ")) || !*TZ)
return;
strncpy(tzname[0], TZ, 3);
timezone = atol(TZ+=3) * 3600L;
for (i=0; i < 3 && TZ[i] && ( isdigit(TZ[i]) || TZ[i] == '-' ); i++)
;
if (TZ[i])
strncpy(tzname[1], TZ+i, 3);
else
*tzname[1] = '\0';
daylight = *tzname[1] != '\0';
}
/*
* _isindst - Tells whether Xenix-type time value falls under DST
*
* This is the rule for years before 1987:
* a time is in DST iff it is on or after 02:00:00 on the last Sunday
* in April and before 01:00:00 on the last Sunday in October.
* This is the rule for years starting with 1987:
* a time is in DST iff it is on or after 02:00:00 on the first Sunday
* in April and before 01:00:00 on the last Sunday in October.
*
* ENTRY tb - 'time' structure holding broken-down time value
*
* RETURN 1 if time represented is in DST, else 0
*/
int _isindst(REG1 struct tm *tb)
{
int mdays;
REG2 int yr;
int lastsun;
/* If the month is before April or after October, then we know
immediately
* it can't be DST. */
if (tb->tm_mon < 3 || tb->tm_mon > 9)
return(0);
/* If the month is after April and before October then we know
immediately
* it must be DST. */
if (tb->tm_mon > 3 && tb->tm_mon < 9)
return(1);
/*
* Now for the hard part. Month is April or October; see if date
* falls between appropriate Sundays.
*/
/*
* The objective for years before 1987 (after 1986) is to determine
* if the day is on or after 2:00 am on the last (first) Sunday in
April,
* or before 1:00 am on the last Sunday in October.
*
* We know the year-day (0..365) of the current time structure. We must
* determine the year-day of the last (first) Sunday in this month,
* April or October, and then do the comparison.
*
* To determine the year-day of the last Sunday, we do the following:
* 1. Get the year-day of the last day of the current month (Apr
or Oct)
* 2. Determine the week-day number of #1,
* which is defined as 0 = Sun, 1 = Mon, ... 6 = Sat
* 3. Subtract #2 from #1
*
* To determine the year-day of the first Sunday, we do the following:
* 1. Get the year-day of the 7th day of the current month
(April)
* 2. Determine the week-day number of #1,
* which is defined as 0 = Sun, 1 = Mon, ... 6 = Sat
* 3. Subtract #2 from #1
*/
yr = tb->tm_year + 1900; /* To see if this is a leap-year */
/* First we get #1. The year-days for each month are stored in _days[]
* they're all off by -1 */
if (yr > 1986 && tb->tm_mon == 3)
mdays = 7 + _days[tb->tm_mon];
else
mdays = _days[tb->tm_mon+1];
/* if this is a leap-year, add an extra day */
if (!(yr & 3))
mdays++;
/* mdays now has #1 */
yr = tb->tm_year - 70;
/* Now get #2. We know the week-day number of the beginning of the
epoch,
* Jan. 1, 1970, which is defined as the constant Day1. We then add the
* number of days that have passed from Day1 to the day of #2
* mdays + 365 * yr
* correct for the leap years which intervened
* + (yr + 1)/ 4
* and take the result mod 7, except that 0 must be mapped to 7.
* This is #2, which we then subtract from #1, mdays
*/
lastsun = mdays - ((mdays + 365*yr + ((yr+1)/4) + Day1) % 7);
/* Now we know 1 and 3; we're golden: */
return (tb->tm_mon==3
? (tb->tm_yday > lastsun ||
(tb->tm_yday == lastsun && tb->tm_hour >= 2))
: (tb->tm_yday < lastsun ||
(tb->tm_yday == lastsun && tb->tm_hour < 1)));
}
------------------------------------------------
"Dan Lanciani" wrote in message
news:1338586@news1.IPSWITCHS.CMM...
> In KB article 39908 (http://support.microsoft.com/kb/39908) Microsoft
> says to correct the DST problem by obtaining the "run-time library
> source code available for the time functions..." This refers to 16-bit
> products from MSC5.1 through VC1.5. Where does one obtain these sources?
> They did not come originally with the products (only startup source was
> supplied) and the oldest I could find for download was VC20. I
> particularly
> need MSC6.0a, but VC1.5[2] would be good as well.
>
> Dan Lanciani
> ddl@danlan.*com
-
Re: C library source for tzset?
In comp.os.msdos.programmer message <4603cde5$0$746$5fc3050@dreader2.new
s.tiscali.nl>, Fri, 23 Mar 2007 13:54:00, Matt Claessen
posted:
>Here is your source, from the MSC 6.0 RTL
>*tzset.c - set timezone information and see if we're in daylight time
>*
>* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved.
Probably they failed to perceive that the USA would decide, in 2005, to
change its rules with effect from 2007-03-01.
> * This is the rule for years before 1987:
I doubt the accuracy of that - for some of the years before 1987, yes.
> /* if this is a leap-year, add an extra day */
> if (!(yr & 3))
> mdays++;
Y2.1K error.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web - w. FAQish topics, links, acronyms
PAS EXE etc : - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
-
Re: C library source for tzset?
In article <4603cde5$0$746$5fc3050@dreader2.news.tiscali.nl>, nospam@tiscali.nl (Matt Claessen) writes:
| Hi,
|
| I tried to send email to the address you gave (minus the *), but it bounced.
|
| Here is your source, from the MSC 6.0 RTL
Thanks! It looks like I need the matching internal include files (e.g.,
ctime.h, internal.h, probably os2dll.h) as well. Can you tell me where
to download them?
Dan Lanciani
ddl@danlan.*com