[Python-checkins] python/nondist/sandbox/datetime datetime.c,1.56,1.57 obj_timetz.c,1.5,1.6
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Wed, 11 Dec 2002 13:29:58 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv1641
Modified Files:
datetime.c obj_timetz.c
Log Message:
timetz repr(), str() and isoformat() may be working now.
Index: datetime.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** datetime.c 11 Dec 2002 20:57:57 -0000 1.56
--- datetime.c 11 Dec 2002 21:29:56 -0000 1.57
***************
*** 755,759 ****
*/
static int
! format_timezone(char *buf, int buflen, const char *sep,
PyObject *tzinfo, PyObject *tzinfoarg)
{
--- 755,759 ----
*/
static int
! format_utcoffset(char *buf, int buflen, const char *sep,
PyObject *tzinfo, PyObject *tzinfoarg)
{
Index: obj_timetz.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_timetz.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** obj_timetz.c 11 Dec 2002 20:57:58 -0000 1.5
--- obj_timetz.c 11 Dec 2002 21:29:56 -0000 1.6
***************
*** 100,124 ****
}
! static PyObject *
! timetz_str(PyDateTime_TimeTZ *self)
! {
! return PyObject_CallMethod((PyObject *)self, "isoformat", "()");
! }
static PyObject *
timetz_isoformat(PyDateTime_TimeTZ *self)
{
! char buffer[100];
! /* Reuse the time format code from the datetime type. */
! PyDateTime_DateTime datetime;
! PyDateTime_DateTime *pdatetime = &datetime;
! /* Copy over just the time bytes. */
! memcpy(pdatetime->data + _PyDateTime_DATE_DATASIZE,
! self->data,
! _PyDateTime_TIME_DATASIZE);
! isoformat_time(pdatetime, buffer, sizeof(buffer));
! return PyString_FromString(buffer);
}
--- 100,124 ----
}
! /* Note: tp_str is inherited from time. */
static PyObject *
timetz_isoformat(PyDateTime_TimeTZ *self)
{
! char buf[100];
! PyObject *result = time_isoformat((PyDateTime_Time *)self);
! if (result == NULL)
! return NULL;
! if (self->tzinfo == Py_None)
! return result;
! /* We need to append the UTC offset. */
! if (format_utcoffset(buf, sizeof(buf), ":", self->tzinfo,
! (PyObject *)self) < 0) {
! Py_DECREF(result);
! return NULL;
! }
! PyString_ConcatAndDel(&result, PyString_FromString(buf));
! return result;
}
***************
*** 307,311 ****
(hashfunc)timetz_hash, /* tp_hash */
0, /* tp_call */
! (reprfunc)timetz_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
--- 307,311 ----
(hashfunc)timetz_hash, /* tp_hash */
0, /* tp_call */
! 0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */