[Python-checkins] python/dist/src/Modules datetimemodule.c,1.40,1.41

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Mon, 20 Jan 2003 14:54:40 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv20501/python/Modules

Modified Files:
	datetimemodule.c 
Log Message:
New rule for tzinfo subclasses handling both standard and daylight time:
When daylight time ends, an hour repeats on the local clock (for example,
in US Eastern, the clock jumps from 1:59 back to 1:00 again).  Times in
the repeated hour are ambiguous.  A tzinfo subclass that wants to play
with astimezone() needs to treat times in the repeated hour as being
standard time.  astimezone() previously required that such times be
treated as daylight time.  There seems no killer argument either way,
but Guido wants the standard-time version, and it does seem easier the
new way to code both American (local-time based) and European (UTC-based)
switch rules, and the astimezone() implementation is simpler.


Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** datetimemodule.c	11 Jan 2003 03:39:11 -0000	1.40
--- datetimemodule.c	20 Jan 2003 22:54:38 -0000	1.41
***************
*** 4047,4051 ****
  	PyObject *result;
  	PyObject *temp;
! 	int selfoff, resoff, dst1, dst2;
  	int none;
  	int delta;
--- 4047,4051 ----
  	PyObject *result;
  	PyObject *temp;
! 	int selfoff, resoff, dst1;
  	int none;
  	int delta;
***************
*** 4129,4152 ****
  	if (temp == NULL)
  		goto Fail;
! 
! 	dst2 = call_dst(tzinfo, temp, &none);
! 	if (dst2 == -1 && PyErr_Occurred()) {
! 		Py_DECREF(temp);
! 		goto Fail;
! 	}
! 	if (none) {
! 		Py_DECREF(temp);
! 		goto Inconsistent;
! 	}
! 
! 	if (dst1 == dst2) {
! 		/* The normal case:  we want temp, not result. */
! 		Py_DECREF(result);
! 		result = temp;
! 	}
! 	else {
! 		/* The "unspellable hour" at the end of DST. */
! 		Py_DECREF(temp);
! 	}
  	return result;
  
--- 4129,4134 ----
  	if (temp == NULL)
  		goto Fail;
! 	Py_DECREF(result);
! 	result = temp;
  	return result;