| ︙ | | | ︙ | |
841
842
843
844
845
846
847
848
849
850
851
852
853
854
|
struct tm *
TclpGetDate(
CONST time_t *t,
int useGMT)
{
struct tm *tmPtr;
time_t time;
if (!useGMT) {
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
# undef timezone /* prevent conflict with timezone() function */
long timezone = 0;
#endif
|
>
>
>
>
>
|
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
|
struct tm *
TclpGetDate(
CONST time_t *t,
int useGMT)
{
struct tm *tmPtr;
time_t time;
#if defined(_WIN64) || (defined(_USE_64BIT_TIME_T) || (defined(_MSC_VER) && _MSC_VER < 1400))
# define t2 *t /* no need to cripple time to 32-bit */
#else
time_t t2 = *(__time32_t *)t;
#endif
if (!useGMT) {
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
# undef timezone /* prevent conflict with timezone() function */
long timezone = 0;
#endif
|
| ︙ | | | ︙ | |
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
|
#ifdef __BORLANDC__
#define LOCALTIME_VALIDITY_BOUNDARY SECSPERDAY
#else
#define LOCALTIME_VALIDITY_BOUNDARY 0
#endif
if (*t >= LOCALTIME_VALIDITY_BOUNDARY) {
return TclpLocaltime(t);
}
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
_get_timezone(&timezone);
#endif
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)) {
tmPtr = ComputeGMT(&time);
} else {
tmPtr = ComputeGMT(t);
tzset();
/*
* Add the bias directly to the tm structure to avoid overflow.
* Propagate seconds overflow into minutes, hours and days.
*/
|
|
|
|
|
|
|
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
|
#ifdef __BORLANDC__
#define LOCALTIME_VALIDITY_BOUNDARY SECSPERDAY
#else
#define LOCALTIME_VALIDITY_BOUNDARY 0
#endif
if (t2 >= LOCALTIME_VALIDITY_BOUNDARY) {
return TclpLocaltime(&t2);
}
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
_get_timezone(&timezone);
#endif
time = t2 - 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 (t2 < (LONG_MAX - 2*SECSPERDAY) && t2 > (LONG_MIN + 2*SECSPERDAY)) {
tmPtr = ComputeGMT(&time);
} else {
tmPtr = ComputeGMT(&t2);
tzset();
/*
* Add the bias directly to the tm structure to avoid overflow.
* Propagate seconds overflow into minutes, hours and days.
*/
|
| ︙ | | | ︙ | |
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
|
time /= 24;
tmPtr->tm_mday += (int)time;
tmPtr->tm_yday += (int)time;
tmPtr->tm_wday = (tmPtr->tm_wday + (int)time) % 7;
}
} else {
tmPtr = ComputeGMT(t);
}
return tmPtr;
}
/*
*----------------------------------------------------------------------
*
|
|
|
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
|
time /= 24;
tmPtr->tm_mday += (int)time;
tmPtr->tm_yday += (int)time;
tmPtr->tm_wday = (tmPtr->tm_wday + (int)time) % 7;
}
} else {
tmPtr = ComputeGMT(&t2);
}
return tmPtr;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | | | ︙ | |
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
|
{
/*
* The MS implementation of gmtime is thread safe because it returns the
* time in a block of thread-local storage, and Windows does not provide a
* Posix gmtime_r function.
*/
return gmtime(timePtr);
}
/*
*----------------------------------------------------------------------
*
* TclpLocaltime --
*
|
>
>
>
>
|
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
|
{
/*
* The MS implementation of gmtime is thread safe because it returns the
* time in a block of thread-local storage, and Windows does not provide a
* Posix gmtime_r function.
*/
#if defined(_WIN64) || defined(_USE_64BIT_TIME_T) || (defined(_MSC_VER) && _MSC_VER < 1400)
return gmtime(timePtr);
#else
return _gmtime32((CONST __time32_t *)timePtr);
#endif
}
/*
*----------------------------------------------------------------------
*
* TclpLocaltime --
*
|
| ︙ | | | ︙ | |
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
|
{
/*
* The MS implementation of localtime is thread safe because it returns
* the time in a block of thread-local storage, and Windows does not
* provide a Posix localtime_r function.
*/
return localtime(timePtr);
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetTimeProc --
*
|
>
>
>
>
|
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
|
{
/*
* The MS implementation of localtime is thread safe because it returns
* the time in a block of thread-local storage, and Windows does not
* provide a Posix localtime_r function.
*/
#if defined(_WIN64) || defined(_USE_64BIT_TIME_T) || (defined(_MSC_VER) && _MSC_VER < 1400)
return localtime(timePtr);
#else
return _localtime32((CONST __time32_t *)timePtr);
#endif
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetTimeProc --
*
|
| ︙ | | | ︙ | |