datetime escapes the sandbox. The Windows build is all set. I leave it

to others to argue about how to build it on other platforms (on Windows
it's in its own DLL).
This commit is contained in:
Tim Peters 2002-12-16 20:18:38 +00:00
parent 786ddb29c9
commit 2a799bf77a
8 changed files with 7456 additions and 1 deletions

125
Include/datetime.h Normal file
View File

@ -0,0 +1,125 @@
/* datetime.h
*/
#ifndef DATETIME_H
#define DATETIME_H
/* Fields are packed into successive bytes, each viewed as unsigned and
* big-endian, unless otherwise noted:
*
* byte offset
* 0 year 2 bytes, 1-9999
* 2 month 1 byte, 1-12
* 3 day 1 byte, 1-31
* 4 hour 1 byte, 0-23
* 5 minute 1 byte, 0-59
* 6 second 1 byte, 0-59
* 7 usecond 3 bytes, 0-999999
* 10
*/
/* # of bytes for year, month, and day. */
#define _PyDateTime_DATE_DATASIZE 4
/* # of bytes for hour, minute, second, and usecond. */
#define _PyDateTime_TIME_DATASIZE 6
/* # of bytes for year, month, day, hour, minute, second, and usecond. */
#define _PyDateTime_DATETIME_DATASIZE 10
typedef struct
{
PyObject_HEAD
long hashcode;
unsigned char data[_PyDateTime_DATE_DATASIZE];
} PyDateTime_Date;
typedef struct
{
PyObject_HEAD
long hashcode;
unsigned char data[_PyDateTime_DATETIME_DATASIZE];
} PyDateTime_DateTime;
typedef struct
{
PyObject_HEAD
long hashcode;
unsigned char data[_PyDateTime_DATETIME_DATASIZE];
PyObject *tzinfo;
} PyDateTime_DateTimeTZ;
typedef struct
{
PyObject_HEAD
long hashcode;
unsigned char data[_PyDateTime_TIME_DATASIZE];
} PyDateTime_Time;
typedef struct
{
PyObject_HEAD
long hashcode;
unsigned char data[_PyDateTime_TIME_DATASIZE];
PyObject *tzinfo;
} PyDateTime_TimeTZ;
typedef struct
{
PyObject_HEAD
long hashcode; /* -1 when unknown */
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
int seconds; /* 0 <= seconds < 24*3600 is invariant */
int microseconds; /* 0 <= microseconds < 1000000 is invariant */
} PyDateTime_Delta;
typedef struct
{
PyObject_HEAD /* a pure abstract base clase */
} PyDateTime_TZInfo;
/* Apply for date, datetime, and datetimetz instances. */
#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \
((PyDateTime_Date*)o)->data[1])
#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2])
#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3])
#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4])
#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5])
#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6])
#define PyDateTime_DATE_GET_MICROSECOND(o) \
((((PyDateTime_DateTime*)o)->data[7] << 16) | \
(((PyDateTime_DateTime*)o)->data[8] << 8) | \
((PyDateTime_DateTime*)o)->data[9])
/* Apply for time and timetz instances. */
#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0])
#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1])
#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2])
#define PyDateTime_TIME_GET_MICROSECOND(o) \
((((PyDateTime_Time*)o)->data[3] << 16) | \
(((PyDateTime_Time*)o)->data[4] << 8) | \
((PyDateTime_Time*)o)->data[5])
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
#define PyDate_CheckExact(op) ((op)->ob_type == &PyDateTime_DateType)
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
#define PyDateTime_CheckExact(op) ((op)->ob_type == &PyDateTime_DateTimeType)
#define PyDateTimeTZ_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeTZType)
#define PyDateTimeTZ_CheckExact(op) ((op)->ob_type == &PyDateTime_DateTimeTZType)
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
#define PyTime_CheckExact(op) ((op)->ob_type == &PyDateTime_TimeType)
#define PyTimeTZ_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeTZType)
#define PyTimeTZ_CheckExact(op) ((op)->ob_type == &PyDateTime_TimeTZType)
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
#define PyDelta_CheckExact(op) ((op)->ob_type == &PyDateTime_DeltaType)
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
#define PyTZInfo_CheckExact(op) ((op)->ob_type == &PyDateTime_TZInfoType)
#endif

2128
Lib/test/test_datetime.py Normal file

File diff suppressed because it is too large Load Diff

5075
Modules/datetimemodule.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ is selected, and the DLL subject to fixups. Apparently, these
fixups are very slow, and significant performance gains can be
made by selecting a good base address.
This document is to allocate base addresses to core Python
This document is to allocate base addresses to core Python
and Python .PYD files, to give a better change of optimal performance.
This base address is passed to the linker using the /BASE
command line switch.
@ -31,6 +31,7 @@ More standard extensions 1D100000 - 1e000000
- unicodedata 1D120000 - 1D160000
- winsound 1D160000 - 1D170000
- bZ2 1D170000 - 1D180000
- datetime 1D180000 - 1D190000
Other extension modules
- win32api 1e200000 - 1e220000

99
PCbuild/datetime.dsp Normal file
View File

@ -0,0 +1,99 @@
# Microsoft Developer Studio Project File - Name="datetime" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=datetime - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "datetime.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "datetime.mak" CFG="datetime - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "datetime - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "datetime - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "datetime"
# PROP Scc_LocalPath ".."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "datetime - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "."
# PROP Intermediate_Dir "x86-temp-release\datetime"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D180000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./datetime.pyd"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "datetime - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "."
# PROP Intermediate_Dir "x86-temp-debug\datetime"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D180000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt" /out:"./datetime_d.pyd" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "datetime - Win32 Release"
# Name "datetime - Win32 Debug"
# Begin Source File
SOURCE=..\Modules\datetimemodule.c
# End Source File
# End Target
# End Project

View File

@ -129,6 +129,21 @@ Package=<4>
###############################################################################
Project: "datetime"=.\datetime.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name pythoncore
End Project Dependency
}}}
###############################################################################
Project: "mmap"=.\mmap.dsp - Package Owner=<4>
Package=<5>

View File

@ -1739,6 +1739,11 @@ item: Install File
Destination=%MAINDIR%\DLLs\bz2.pyd
Flags=0000000000000010
end
item: Install File
Source=.\datetime.pyd
Destination=%MAINDIR%\DLLs\datetime.pyd
Flags=0000000000000010
end
item: Install File
Source=.\mmap.pyd
Destination=%MAINDIR%\DLLs\mmap.pyd
@ -1826,6 +1831,11 @@ item: Install File
Destination=%MAINDIR%\libs\bz2.lib
Flags=0000000000000010
end
item: Install File
Source=.\datetime.lib
Destination=%MAINDIR%\libs\datetime.lib
Flags=0000000000000010
end
item: Install File
Source=.\mmap.lib
Destination=%MAINDIR%\libs\mmap.lib

View File

@ -48,6 +48,8 @@ _symtable
_testcapi
tests of the Python C API, run via Lib/test/test_capi.py, and
implemented by module Modules/_testcapimodule.c
datetime
datetimemodule.c
mmap
mmapmodule.c
parser