diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-01-08 20:40:01 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-01-08 20:40:01 (GMT) |
commit | 0bf60bd67f6a81feb62a44e22b7ecd9aad78555a (patch) | |
tree | 4d544f1e1ec014237e1f4ecb0331af4130f67203 /Modules/datetimemodule.c | |
parent | 034d97605d5300721310a0d7320b41f67237007b (diff) | |
download | cpython-0bf60bd67f6a81feb62a44e22b7ecd9aad78555a.zip cpython-0bf60bd67f6a81feb62a44e22b7ecd9aad78555a.tar.gz cpython-0bf60bd67f6a81feb62a44e22b7ecd9aad78555a.tar.bz2 |
Utterly minimal changes to collapse datetimetz into datetime, and timetz
into time. This is little more than *exporting* the datetimetz object
under the name "datetime", and similarly for timetz. A good implementation
of this change requires more work, but this is fully functional if you
don't stare too hard at the internals (e.g., right now a type named
"datetime" shows up as a base class of the type named "datetime"). The
docs also need extensive revision, not part of this checkin.
Diffstat (limited to 'Modules/datetimemodule.c')
-rw-r--r-- | Modules/datetimemodule.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index b01f139..ea8302f 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -3345,10 +3345,11 @@ datetime_getdate(PyDateTime_DateTime *self) static PyObject * datetime_gettime(PyDateTime_DateTime *self) { - return new_time(DATE_GET_HOUR(self), - DATE_GET_MINUTE(self), - DATE_GET_SECOND(self), - DATE_GET_MICROSECOND(self)); + return new_timetz(DATE_GET_HOUR(self), + DATE_GET_MINUTE(self), + DATE_GET_SECOND(self), + DATE_GET_MICROSECOND(self), + Py_None); } /* Pickle support. Quite a maze! */ @@ -3457,8 +3458,7 @@ static PyMethodDef datetime_methods[] = { PyDoc_STR("Return date object with same year, month and day.")}, {"time", (PyCFunction)datetime_gettime, METH_NOARGS, - PyDoc_STR("Return time object with same hour, minute, second and " - "microsecond.")}, + PyDoc_STR("Return time object with same time but with tzinfo=None.")}, {"ctime", (PyCFunction)datetime_ctime, METH_NOARGS, PyDoc_STR("Return ctime() style string.")}, @@ -4403,7 +4403,7 @@ static PyNumberMethods timetz_as_number = { statichere PyTypeObject PyDateTime_TimeTZType = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ - "datetime.timetz", /* tp_name */ + "datetime.time", /* tp_name */ sizeof(PyDateTime_TimeTZ), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)timetz_dealloc, /* tp_dealloc */ @@ -5119,7 +5119,7 @@ static PyNumberMethods datetimetz_as_number = { statichere PyTypeObject PyDateTime_DateTimeTZType = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ - "datetime.datetimetz", /* tp_name */ + "datetime.datetime", /* tp_name */ sizeof(PyDateTime_DateTimeTZ), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)datetimetz_dealloc, /* tp_dealloc */ @@ -5424,24 +5424,17 @@ initdatetime(void) Py_INCREF(&PyDateTime_DateType); PyModule_AddObject(m, "date", (PyObject *) &PyDateTime_DateType); - Py_INCREF(&PyDateTime_DateTimeType); - PyModule_AddObject(m, "datetime", - (PyObject *) &PyDateTime_DateTimeType); - Py_INCREF(&PyDateTime_DeltaType); PyModule_AddObject(m, "timedelta", (PyObject *) &PyDateTime_DeltaType); - Py_INCREF(&PyDateTime_TimeType); - PyModule_AddObject(m, "time", (PyObject *) &PyDateTime_TimeType); - Py_INCREF(&PyDateTime_TZInfoType); PyModule_AddObject(m, "tzinfo", (PyObject *) &PyDateTime_TZInfoType); Py_INCREF(&PyDateTime_TimeTZType); - PyModule_AddObject(m, "timetz", (PyObject *) &PyDateTime_TimeTZType); + PyModule_AddObject(m, "time", (PyObject *) &PyDateTime_TimeTZType); Py_INCREF(&PyDateTime_DateTimeTZType); - PyModule_AddObject(m, "datetimetz", + PyModule_AddObject(m, "datetime", (PyObject *)&PyDateTime_DateTimeTZType); /* A 4-year cycle has an extra leap day over what we'd get from |