[Python-checkins] python/nondist/sandbox/datetime datetime.py,1.74,1.75 doc.txt,1.6,1.7 obj_date.c,1.22,1.23 obj_datetime.c,1.15,1.16
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Wed, 04 Dec 2002 17:39:41 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv3759
Modified Files:
datetime.py doc.txt obj_date.c obj_datetime.c
Log Message:
Fleshed out the docs for class date. Repaired some senseless docstrings.
Noted that date.strftime() doesn't exist in the C implementation, and
that there are no tests of it in the Python implementation either.
Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** datetime.py 3 Dec 2002 21:50:20 -0000 1.74
--- datetime.py 5 Dec 2002 01:39:39 -0000 1.75
***************
*** 496,501 ****
timetuple()
toordinal()
! weekday(), isoweekday(), isocalendar()
! isoformat()
Properties (readonly):
--- 496,503 ----
timetuple()
toordinal()
! weekday()
! isoweekday(), isocalendar(), isoformat()
! ctime()
! strftime()
Properties (readonly):
***************
*** 1036,1044 ****
timetuple()
ctime()
strftime()
- toordinal()
- weekday(), isoweekday(), isocalendar()
- isoformat()
Properties (readonly):
--- 1038,1046 ----
timetuple()
+ toordinal()
+ weekday()
+ isoweekday(), isocalendar(), isoformat()
ctime()
strftime()
Properties (readonly):
***************
*** 1228,1233 ****
"""Return the time formatted according to ISO.
! This is 'YYYY-MM-DD HH:MM:SS.mmmmmm'
! where -xx:yy is the timezone offset.
Optional argument sep specifies the separator between date and
--- 1230,1234 ----
"""Return the time formatted according to ISO.
! This is 'YYYY-MM-DD HH:MM:SS.mmmmmm'.
Optional argument sep specifies the separator between date and
Index: doc.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/doc.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** doc.txt 5 Dec 2002 00:40:30 -0000 1.6
--- doc.txt 5 Dec 2002 01:39:39 -0000 1.7
***************
*** 238,241 ****
--- 238,303 ----
- pickling
+ Instance methods:
+
+ - timetuple()
+ Return a 9-element tuple of the form returned by time.localtime().
+ The hours, minutes and seconds are 0, and the DST flag is -1.
+ d.timetuple() is equivalent to
+ (d.year, d.month, d.day,
+ 0, 0, 0, # h, m, s
+ d.weekday(), # 0 is Monday
+ d.toordinal() - date(d.year, 1, 1).toordinal() + 1, # day of year
+ -1)
+
+ - toordinal()
+ Return the proleptic Gregorian ordinal of the date, where January 1
+ of year 1 has ordinal 1. For any date object d,
+ date.fromordinal(d.toordinal()) == d.
+
+ - weekday()
+ Return the day of the week as an integer, where Monday is 0 and
+ Sunday is 6. For example, date(2002, 12, 4).weekday() == 2, a
+ Wednesday.
+ See also isoweekday().
+
+ - isoweekday()
+ Return the day of the week as an integer, where Monday is 1 and
+ Sunday is 7. For example, date(2002, 12, 4).isoweekday() == 3, a
+ Wednesday.
+ See also weekday() and isocalendar().
+
+ - isocalendar()
+ Return a 3-tuple, (ISO year, ISO week number, ISO weekday).
+
+ The ISO calendar is a widely used variant of the Gregorian calendar.
+ See <http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm>
+ for a good explanation.
+
+ The ISO year consists of 52 or 53 full weeks, and where a week starts
+ on a Monday and ends on a Sunday. The first week of an ISO year is
+ the first (Gregorian) calendar week of a year containing a Thursday.
+ This is called week number 1, and the ISO year of that Thursday is
+ the same as its Gregorian year.
+
+ For example, 2004 begins on a Thursday, so the first week of ISO
+ year 2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan
+ 2004, so that
+
+ date(2003, 12, 29).isocalendar() == (2004, 1, 1)
+ date(2004, 1, 4).isocalendar() == (2004, 1, 7)
+
+ - isoformat()
+ Return a string representing the date in ISO 8601 format,
+ 'YYYY-MM-DD'. For example,
+ date(2002, 12, 4).isoformat() == '2002-12-04'.
+
+ - ctime()
+ Return a string representing the date, for example
+ date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'.
+ d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple())).
+
+ - strftime(format)
+ XXX And the C implementation doesn't have this yet either.
+ XXX And there are no tests for it.
Index: obj_date.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_date.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** obj_date.c 4 Dec 2002 22:18:49 -0000 1.22
--- obj_date.c 5 Dec 2002 01:39:39 -0000 1.23
***************
*** 496,499 ****
--- 496,500 ----
}
+ /* XXX strftime is missing. */
static PyMethodDef date_methods[] = {
/* Class methods: */
***************
*** 515,528 ****
"Return a 3-tuple containing ISO year, week number, and weekday.\n\n"
"The first ISO week of the year is the (Mon-Sun) week containing the\n"
! "year's first Thursday; everything rest derives from that."},
{"isoformat", (PyCFunction)date_isoformat, METH_KEYWORDS,
! "Return the day of the week represented by the date.\n"
! "Monday == 1 ... Sunday == 7"},
{"isoweekday", (PyCFunction)date_isoweekday, METH_NOARGS,
"Return the day of the week represented by the date.\n"
"Monday == 1 ... Sunday == 7"},
{"toordinal", (PyCFunction)date_toordinal, METH_NOARGS,
! "Return proleptic Gregorian ordinal for the year, month and day.\n"
! "January 1 of year 1 is day 1."},
{"weekday", (PyCFunction)date_weekday, METH_NOARGS,
"Return the day of the week represented by the date.\n"
--- 516,527 ----
"Return a 3-tuple containing ISO year, week number, and weekday.\n\n"
"The first ISO week of the year is the (Mon-Sun) week containing the\n"
! "year's first Thursday; everything else derives from that."},
{"isoformat", (PyCFunction)date_isoformat, METH_KEYWORDS,
! "Return string in ISO 8601 format, YYYY-MM-DD."},
{"isoweekday", (PyCFunction)date_isoweekday, METH_NOARGS,
"Return the day of the week represented by the date.\n"
"Monday == 1 ... Sunday == 7"},
{"toordinal", (PyCFunction)date_toordinal, METH_NOARGS,
! "Return proleptic Gregorian ordinal. January 1 of year 1 is day 1."},
{"weekday", (PyCFunction)date_weekday, METH_NOARGS,
"Return the day of the week represented by the date.\n"
Index: obj_datetime.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_datetime.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** obj_datetime.c 4 Dec 2002 05:08:14 -0000 1.15
--- obj_datetime.c 5 Dec 2002 01:39:39 -0000 1.16
***************
*** 464,469 ****
"Return ctime() style string."},
{"isoformat", (PyCFunction)datetime_isoformat, METH_KEYWORDS,
! "Return the day of the week represented by the datetime.\n"
! "Monday == 1 ... Sunday == 7"},
{"__setstate__", (PyCFunction)datetime_setstate, METH_O,
PyDoc_STR("__setstate__(state)")},
--- 464,470 ----
"Return ctime() style string."},
{"isoformat", (PyCFunction)datetime_isoformat, METH_KEYWORDS,
! "[sep] -> string in ISO 8601 format, YYYY-MM-DDTHH:MM:SS.mmmmmm.\n"
! "\n\nsep is used to separate the year from the time, and defaults\n"
! "to 'T'."},
{"__setstate__", (PyCFunction)datetime_setstate, METH_O,
PyDoc_STR("__setstate__(state)")},