[Python-checkins] python/nondist/sandbox/datetime obj_datetime.c,1.56,1.57
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sat, 14 Dec 2002 10:01:15 -0800
- Previous message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.70,1.71 datetime.h,1.17,1.18 obj_date.c,1.53,1.54 obj_datetime.c,1.55,1.56 obj_datetimetz.c,1.15,1.16 obj_delta.c,1.27,1.28 obj_time.c,1.17,1.18 obj_timetz.c,1.27,1.28
- Next message: [Python-checkins] python/nondist/sandbox/datetime obj_datetimetz.c,1.16,1.17
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv27482
Modified Files:
obj_datetime.c
Log Message:
Simplified datetime_hash().
Index: obj_datetime.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_datetime.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** obj_datetime.c 14 Dec 2002 17:42:09 -0000 1.56
--- obj_datetime.c 14 Dec 2002 18:01:11 -0000 1.57
***************
*** 63,67 ****
if (check_time_args(hour, minute, second, usecond) < 0)
return NULL;
! self = new_datetime(year, month, day,
hour, minute, second, usecond);
}
--- 63,67 ----
if (check_time_args(hour, minute, second, usecond) < 0)
return NULL;
! self = new_datetime(year, month, day,
hour, minute, second, usecond);
}
***************
*** 497,500 ****
--- 497,501 ----
naivety n;
int offset;
+ PyObject *temp;
n = classify_object((PyObject *)self, &offset);
***************
*** 502,543 ****
if (n == OFFSET_ERROR)
return -1;
! if (n == OFFSET_NAIVE) {
! PyObject *temp = datetime_getstate(self);
! if (temp != NULL) {
! self->hashcode = PyObject_Hash(temp);
! Py_DECREF(temp);
! }
! }
else {
int days;
int seconds;
- PyDateTime_Delta *delta;
assert(n == OFFSET_AWARE);
assert(PyDateTimeTZ_Check(self));
- /* It doesn't really matter what we do now, except
- * that we have to ensure that datetimetz objects that
- * compare equal have equal hashcodes. So something
- * based on subtracting offset minutes is needed.
- * CAUTION: it's not OK to return right away if
- * offset==0: we need to go thru the whole business
- * below so that, e.g., a datetimetz with hour=5 and
- * offset=-60 gets the same hash code as a datetimetz
- * with hour=6 and offset=0.
- */
days = ymd_to_ord(GET_YEAR(self),
GET_MONTH(self),
GET_DAY(self));
! seconds = DATE_GET_HOUR(self) * 3600L +
! (DATE_GET_MINUTE(self) - offset) * 60L +
DATE_GET_SECOND(self);
! delta = (PyDateTime_Delta *)new_delta(days,
! seconds,
! DATE_GET_MICROSECOND(self),
! 1);
! if (delta == NULL)
! return -1;
! self->hashcode = delta_hash(delta);
! Py_DECREF(delta);
}
}
--- 503,530 ----
if (n == OFFSET_ERROR)
return -1;
!
! /* Reduce this to a hash of another object. */
! if (n == OFFSET_NAIVE)
! temp = datetime_getstate(self);
else {
int days;
int seconds;
assert(n == OFFSET_AWARE);
assert(PyDateTimeTZ_Check(self));
days = ymd_to_ord(GET_YEAR(self),
GET_MONTH(self),
GET_DAY(self));
! seconds = DATE_GET_HOUR(self) * 3600 +
! (DATE_GET_MINUTE(self) - offset) * 60 +
DATE_GET_SECOND(self);
! temp = new_delta(days,
! seconds,
! DATE_GET_MICROSECOND(self),
! 1);
! }
! if (temp != NULL) {
! self->hashcode = PyObject_Hash(temp);
! Py_DECREF(temp);
}
}
- Previous message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.70,1.71 datetime.h,1.17,1.18 obj_date.c,1.53,1.54 obj_datetime.c,1.55,1.56 obj_datetimetz.c,1.15,1.16 obj_delta.c,1.27,1.28 obj_time.c,1.17,1.18 obj_timetz.c,1.27,1.28
- Next message: [Python-checkins] python/nondist/sandbox/datetime obj_datetimetz.c,1.16,1.17
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]