Commit 7dfb8456 authored by Tim Peters's avatar Tim Peters

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.
parent e2f83695
This diff is collapsed.
......@@ -31,6 +31,13 @@ Extension modules
- datetime changes:
The datetime and datetimetz classes have been collapsed into a single
datetime class, and likewise the time and timetz classes into a single
time class. Previously, a datetimetz object with tzinfo=None acted
exactly like a datetime object, and similarly for timetz. This wasn't
enough of a difference to justify distinct classes, and life is simpler
now.
today() and now() now round system timestamps to the closest
microsecond <http://www.python.org/sf/661086>. This repairs an
irritation most likely seen on Windows systems.
......@@ -1202,7 +1209,7 @@ Mac
- MacPython no longer maps both \r and \n to \n on input for any text file.
This feature has been replaced by universal newline support (PEP278).
- The default encoding for Python sourcefiles in MacPython-OS9 is no longer
mac-roman (or whatever your local Mac encoding was but "ascii", like on
other platforms. If you really need sourcefiles with Mac characters in them
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment