Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(85477)

Delta Between Two Patch Sets: Modules/_datetimemodule.c

Issue 17267: datetime.time support for '+' and 'now'
Left Patch Set: Created 6 years, 6 months ago
Right Patch Set: Created 6 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« Lib/datetime.py ('K') | « Lib/test/datetimetester.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* C implementation for the date/time type documented at 1 /* C implementation for the date/time type documented at
2 * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage 2 * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
3 */ 3 */
4 4
5 #include "Python.h" 5 #include "Python.h"
6 #include "structmember.h" 6 #include "structmember.h"
7 7
8 #include <time.h> 8 #include <time.h>
9 9
10 /* Differentiate between building the core module and building extension 10 /* Differentiate between building the core module and building extension
(...skipping 3827 matching lines...) Expand 10 before | Expand all | Expand 10 after
3838 3838
3839 /* 3839 /*
3840 * Time arithmetic 3840 * Time arithmetic
3841 */ 3841 */
3842 3842
3843 /* time + timedelta -> time 3843 /* time + timedelta -> time
3844 * 3844 *
3845 .*/ 3845 .*/
3846 static PyObject * 3846 static PyObject *
3847 add_time_timedelta(PyDateTime_Time *time, PyDateTime_Delta *delta, 3847 add_time_timedelta(PyDateTime_Time *time, PyDateTime_Delta *delta,
3848 int factor) 3848 int factor)
Ronald Oussoren 2013/02/25 08:35:59 I'd use "int is_addition" instead of "int factor",
3849 { 3849 {
3850 int hour = TIME_GET_HOUR(time); 3850 int hour = TIME_GET_HOUR(time);
3851 int minute = TIME_GET_MINUTE(time); 3851 int minute = TIME_GET_MINUTE(time);
3852 int second = TIME_GET_SECOND(time) + GET_TD_SECONDS(delta) * factor; 3852 int second = TIME_GET_SECOND(time) + GET_TD_SECONDS(delta) * factor;
3853 int microsecond = TIME_GET_MICROSECOND(time) + 3853 int microsecond = TIME_GET_MICROSECOND(time) +
3854 GET_TD_MICROSECONDS(delta) * factor; 3854 GET_TD_MICROSECONDS(delta) * factor;
3855 3855
3856 assert(factor == 1 || factor == -1); 3856 assert(factor == 1 || factor == -1);
3857 3857
3858 normalize_time(&hour, &minute, &second, &microsecond); 3858 normalize_time(&hour, &minute, &second, &microsecond);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3979 (reprfunc)time_repr, /* tp_repr */ 3979 (reprfunc)time_repr, /* tp_repr */
3980 &time_as_number, /* tp_as_number */ 3980 &time_as_number, /* tp_as_number */
3981 0, /* tp_as_sequence */ 3981 0, /* tp_as_sequence */
3982 0, /* tp_as_mapping */ 3982 0, /* tp_as_mapping */
3983 (hashfunc)time_hash, /* tp_hash */ 3983 (hashfunc)time_hash, /* tp_hash */
3984 0, /* tp_call */ 3984 0, /* tp_call */
3985 (reprfunc)time_str, /* tp_str */ 3985 (reprfunc)time_str, /* tp_str */
3986 PyObject_GenericGetAttr, /* tp_getattro */ 3986 PyObject_GenericGetAttr, /* tp_getattro */
3987 0, /* tp_setattro */ 3987 0, /* tp_setattro */
3988 0, /* tp_as_buffer */ 3988 0, /* tp_as_buffer */
3989 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ 3989 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
3990 time_doc, /* tp_doc */ 3990 time_doc, /* tp_doc */
3991 0, /* tp_traverse */ 3991 0, /* tp_traverse */
3992 0, /* tp_clear */ 3992 0, /* tp_clear */
3993 time_richcompare, /* tp_richcompare */ 3993 time_richcompare, /* tp_richcompare */
3994 0, /* tp_weaklistoffset */ 3994 0, /* tp_weaklistoffset */
3995 0, /* tp_iter */ 3995 0, /* tp_iter */
3996 0, /* tp_iternext */ 3996 0, /* tp_iternext */
3997 time_methods, /* tp_methods */ 3997 time_methods, /* tp_methods */
3998 0, /* tp_members */ 3998 0, /* tp_members */
3999 time_getset, /* tp_getset */ 3999 time_getset, /* tp_getset */
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
5619 enough to say. 5619 enough to say.
5620 5620
5621 In any case, it's clear that the default fromutc() is strong enough to handle 5621 In any case, it's clear that the default fromutc() is strong enough to handle
5622 "almost all" time zones: so long as the standard offset is invariant, it 5622 "almost all" time zones: so long as the standard offset is invariant, it
5623 doesn't matter if daylight time transition points change from year to year, or 5623 doesn't matter if daylight time transition points change from year to year, or
5624 if daylight time is skipped in some years; it doesn't matter how large or 5624 if daylight time is skipped in some years; it doesn't matter how large or
5625 small dst() may get within its bounds; and it doesn't even matter if some 5625 small dst() may get within its bounds; and it doesn't even matter if some
5626 perverse time zone returns a negative dst()). So a breaking case must be 5626 perverse time zone returns a negative dst()). So a breaking case must be
5627 pretty bizarre, and a tzinfo subclass can override fromutc() if it is. 5627 pretty bizarre, and a tzinfo subclass can override fromutc() if it is.
5628 --------------------------------------------------------------------------- */ 5628 --------------------------------------------------------------------------- */
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+