[Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.81,2.82
Guido van Rossum
python-dev@python.org
2000年4月26日 16:40:16 -0400 (EDT)
Update of /projects/cvsroot/python/dist/src/Modules
In directory eric:/projects/python/develop/guido/src/Modules
Modified Files:
timemodule.c
Log Message:
Jack Jansen:
This patch is a workaround for Macintosh, where the GUSI I/O library
(time, stat, etc) use the MacOS epoch of 1-Jan-1904 and the MSL C
library (ctime, localtime, etc) uses the (apparently ANSI standard)
epoch of 1-Jan-1900. Python programs see the MacOS epoch and we
convert values when needed.
Index: timemodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.81
retrieving revision 2.82
diff -C2 -r2.81 -r2.82
*** timemodule.c 2000年03月24日 20:35:20 2.81
--- timemodule.c 2000年04月26日 20:40:13 2.82
***************
*** 42,45 ****
--- 42,53 ----
#ifdef macintosh
#include <time.h>
+ #include <OSUtils.h>
+ #ifdef USE_GUSI2
+ /* GUSI, the I/O library which has the time() function and such uses the
+ ** Mac epoch of 1904. MSL, the C library which has localtime() and so uses
+ ** the ANSI epoch of 1900.
+ */
+ #define GUSI_TO_MSL_EPOCH (4*365*24*60*60)
+ #endif /* USE_GUSI2 */
#else
#include <sys/types.h>
***************
*** 272,275 ****
--- 280,286 ----
struct tm *p;
errno = 0;
+ #if defined(macintosh) && defined(USE_GUSI2)
+ when = when + GUSI_TO_MSL_EPOCH;
+ #endif
p = function(&when);
if (p == NULL) {
***************
*** 481,484 ****
--- 492,498 ----
return NULL;
tt = (time_t)dt;
+ #if defined(macintosh) && defined(USE_GUSI2)
+ tt = tt + GUSI_TO_MSL_EPOCH;
+ #endif
p = ctime(&tt);
if (p == NULL) {
***************
*** 518,521 ****
--- 532,538 ----
return NULL;
}
+ #if defined(macintosh) && defined(USE_GUSI2)
+ tt = tt - GUSI_TO_MSL_EPOCH;
+ #endif
return PyFloat_FromDouble((double)tt);
}