Diff
Not logged in

Differences From Artifact [eb1275c12c]:

To Artifact [3ffd326c00]:


1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19











-
+







/* 
 * tclWinTime.c --
 *
 *	Contains Windows specific versions of Tcl functions that
 *	obtain time values from the operating system.
 *
 * Copyright 1995-1998 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinTime.c,v 1.22 2004/03/18 18:56:04 rmax Exp $
 * RCS: @(#) $Id: tclWinTime.c,v 1.23 2004/03/19 18:33:53 kennykb Exp $
 */

#include "tclWinInt.h"

#define SECSPERDAY (60L * 60L * 24L)
#define SECSPERYEAR (SECSPERDAY * 365L)
#define SECSPER4YEAR (SECSPERYEAR * 4L + SECSPERDAY)
541
542
543
544
545
546
547
548

549
550
551
552
553
554
555
541
542
543
544
545
546
547

548
549
550
551
552
553
554
555







-
+







 *	None.
 *
 *----------------------------------------------------------------------
 */

struct tm *
TclpGetDate(t, useGMT)
    CONST time_t t;
    CONST time_t *t;
    int useGMT;
{
    struct tm *tmPtr;
    time_t time;

    if (!useGMT) {
	tzset();
566
567
568
569
570
571
572
573

574
575

576
577

578
579
580

581
582
583
584
585
586
587
588
589


590
591
592

593
594
595
596
597
598
599
566
567
568
569
570
571
572

573
574

575
576

577
578
579

580
581
582
583
584
585
586
587


588
589
590
591

592
593
594
595
596
597
598
599







-
+

-
+

-
+


-
+







-
-
+
+


-
+







	  since 'localtime' isn't supposed to do this, possibly leading to
	  crashes.
	  Patch: We only call this function if we are at least one day into
	  the epoch, else we handle it ourselves (like we do for times < 0).
	  H. Giese, June 2003
	*/
#ifdef __BORLANDC__
	if (t >= SECSPERDAY) {
	if (*t >= SECSPERDAY) {
#else
	if (t >= 0) {
	if (*t >= 0) {
#endif
	    return localtime(tp);
	    return localtime(t);
	}

	time = t - timezone;
	time = *t - timezone;
	
	/*
	 * If we aren't near to overflowing the long, just add the bias and
	 * use the normal calculation.  Otherwise we will need to adjust
	 * the result at the end.
	 */

	if (t < (LONG_MAX - 2 * SECSPERDAY)
		&& t > (LONG_MIN + 2 * SECSPERDAY)) {
	if (*t < (LONG_MAX - 2 * SECSPERDAY)
		&& *t > (LONG_MIN + 2 * SECSPERDAY)) {
	    tmPtr = ComputeGMT(&time);
	} else {
	    tmPtr = ComputeGMT(&t);
	    tmPtr = ComputeGMT(t);

	    tzset();

	    /*
	     * Add the bias directly to the tm structure to avoid overflow.
	     * Propagate seconds overflow into minutes, hours and days.
	     */
621
622
623
624
625
626
627
628

629
630
631
632
633
634
635
621
622
623
624
625
626
627

628
629
630
631
632
633
634
635







-
+








	    time /= 24;
	    tmPtr->tm_mday += time;
	    tmPtr->tm_yday += time;
	    tmPtr->tm_wday = (tmPtr->tm_wday + time) % 7;
	}
    } else {
	tmPtr = ComputeGMT(&t);
	tmPtr = ComputeGMT(t);
    }
    return tmPtr;
}

/*
 *----------------------------------------------------------------------
 *