[Python-checkins] python/nondist/sandbox/datetime datetime.c,1.75,1.76 obj_date.c,1.55,1.56 obj_time.c,1.18,1.19
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 15 Dec 2002 16:50:13 -0800
- Previous message: [Python-checkins] python/nondist/sandbox/datetime datetime.py,1.108,1.109 doc.txt,1.55,1.56 test_datetime.py,1.69,1.70
- Next message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.76,1.77 doc.txt,1.56,1.57 test_datetime.py,1.70,1.71
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv14054
Modified Files:
datetime.c obj_date.c obj_time.c
Log Message:
Rearranged C strftime() implemenatations so it's *possible* to fix all of
them in one place. Made them keyword functions since they should have
been all along.
Index: datetime.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** datetime.c 15 Dec 2002 18:30:49 -0000 1.75
--- datetime.c 16 Dec 2002 00:50:10 -0000 1.76
***************
*** 767,783 ****
/* I sure don't want to reproduce the strftime code from the time module,
! * so this imports the module and calls it.
*/
static PyObject *
! format_strftime(PyObject *format, PyObject *tuple)
{
PyObject *time;
PyObject *result;
time = PyImport_ImportModule("time");
if (time == NULL)
return NULL;
! result = PyObject_CallMethod(time, "strftime", "OO", format, tuple);
Py_DECREF(time);
return result;
--- 767,789 ----
/* I sure don't want to reproduce the strftime code from the time module,
! * so this imports the module and calls it. Most of the hair is due to
! * giving special meanings to the %z and %Z format codes via a preprocessing
! * step on the format string.
*/
static PyObject *
! wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple)
{
PyObject *time;
PyObject *result;
+ assert(object && format && timetuple);
+ assert(PyString_Check(format));
+
time = PyImport_ImportModule("time");
if (time == NULL)
return NULL;
! result = PyObject_CallMethod(time, "strftime", "OO",
! format, timetuple);
Py_DECREF(time);
return result;
Index: obj_date.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_date.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** obj_date.c 15 Dec 2002 03:55:43 -0000 1.55
--- obj_date.c 16 Dec 2002 00:50:10 -0000 1.56
***************
*** 259,263 ****
static PyObject *
! date_strftime(PyDateTime_Date *self, PyObject *format)
{
/* This method can be inherited, and needs to call the
--- 259,263 ----
static PyObject *
! date_strftime(PyDateTime_Date *self, PyObject *args, PyObject *kw)
{
/* This method can be inherited, and needs to call the
***************
*** 265,274 ****
*/
PyObject *result;
! PyObject *tuple = PyObject_CallMethod((PyObject *)self,
! "timetuple", "()");
if (tuple == NULL)
return NULL;
! result = format_strftime(format, tuple);
Py_DECREF(tuple);
return result;
--- 265,280 ----
*/
PyObject *result;
! PyObject *format;
! PyObject *tuple;
! static char *keywords[] = {"format", NULL};
!
! if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords,
! &PyString_Type, &format))
! return NULL;
+ tuple = PyObject_CallMethod((PyObject *)self, "timetuple", "()");
if (tuple == NULL)
return NULL;
! result = wrap_strftime((PyObject *)self, format, tuple);
Py_DECREF(tuple);
return result;
***************
*** 461,465 ****
PyDoc_STR("Return ctime() style string.")},
! {"strftime", (PyCFunction)date_strftime, METH_O,
PyDoc_STR("format -> strftime() style string.")},
--- 467,471 ----
PyDoc_STR("Return ctime() style string.")},
! {"strftime", (PyCFunction)date_strftime, METH_KEYWORDS,
PyDoc_STR("format -> strftime() style string.")},
Index: obj_time.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_time.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** obj_time.c 14 Dec 2002 17:42:09 -0000 1.18
--- obj_time.c 16 Dec 2002 00:50:10 -0000 1.19
***************
*** 109,125 ****
static PyObject *
! time_strftime(PyDateTime_Time *self, PyObject *format)
{
PyObject *result;
! PyObject *tuple = Py_BuildValue("iiiiiiiii",
! 0, 0, 0, /* year, month, day */
! TIME_GET_HOUR(self),
! TIME_GET_MINUTE(self),
! TIME_GET_SECOND(self),
! 0, 0, -1); /* weekday, daynum, dst */
if (tuple == NULL)
return NULL;
assert(PyTuple_Size(tuple) == 9);
! result = format_strftime(format, tuple);
Py_DECREF(tuple);
return result;
--- 109,133 ----
static PyObject *
! time_strftime(PyDateTime_Time *self, PyObject *args, PyObject *kw)
{
PyObject *result;
! PyObject *format;
! PyObject *tuple;
! static char *keywords[] = {"format", NULL};
!
! if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords,
! &PyString_Type, &format))
! return NULL;
!
! tuple = Py_BuildValue("iiiiiiiii",
! 0, 0, 0, /* year, month, day */
! TIME_GET_HOUR(self),
! TIME_GET_MINUTE(self),
! TIME_GET_SECOND(self),
! 0, 0, -1); /* weekday, daynum, dst */
if (tuple == NULL)
return NULL;
assert(PyTuple_Size(tuple) == 9);
! result = wrap_strftime((PyObject *)self, format, tuple);
Py_DECREF(tuple);
return result;
***************
*** 326,330 ****
PyDoc_STR("Return string in ISO 8601 format, HH:MM:SS[.mmmmmm].")},
! {"strftime", (PyCFunction)time_strftime, METH_O,
PyDoc_STR("format -> strftime() style string.")},
--- 334,338 ----
PyDoc_STR("Return string in ISO 8601 format, HH:MM:SS[.mmmmmm].")},
! {"strftime", (PyCFunction)time_strftime, METH_KEYWORDS,
PyDoc_STR("format -> strftime() style string.")},
- Previous message: [Python-checkins] python/nondist/sandbox/datetime datetime.py,1.108,1.109 doc.txt,1.55,1.56 test_datetime.py,1.69,1.70
- Next message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.76,1.77 doc.txt,1.56,1.57 test_datetime.py,1.70,1.71
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]