[Python-checkins] python/dist/src/Modules datetimemodule.c,1.43,1.44

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 23 Jan 2003 11:58:06 -0800


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

Modified Files:
	datetimemodule.c 
Log Message:
Reimplemented datetime.now() to be useful.


Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** datetimemodule.c	23 Jan 2003 17:20:36 -0000	1.43
--- datetimemodule.c	23 Jan 2003 19:58:02 -0000	1.44
***************
*** 3667,3679 ****
  datetime_now(PyObject *cls, PyObject *args, PyObject *kw)
  {
! 	PyObject *self = NULL;
  	PyObject *tzinfo = Py_None;
! 	static char *keywords[] = {"tzinfo", NULL};
  
! 	if (PyArg_ParseTupleAndKeywords(args, kw, "|O:now", keywords,
! 					&tzinfo)) {
! 		if (check_tzinfo_subclass(tzinfo) < 0)
! 			return NULL;
! 		self = datetime_best_possible(cls, localtime, tzinfo);
  	}
  	return self;
--- 3667,3689 ----
  datetime_now(PyObject *cls, PyObject *args, PyObject *kw)
  {
! 	PyObject *self;
  	PyObject *tzinfo = Py_None;
! 	static char *keywords[] = {"tz", NULL};
  
! 	if (! PyArg_ParseTupleAndKeywords(args, kw, "|O:now", keywords,
! 					  &tzinfo))
! 		return NULL;
! 	if (check_tzinfo_subclass(tzinfo) < 0)
! 		return NULL;
! 
! 	self = datetime_best_possible(cls,
! 				      tzinfo == Py_None ? localtime : gmtime,
! 				      tzinfo);
! 	if (self != NULL && tzinfo != Py_None) {
! 		/* Convert UTC to tzinfo's zone. */
! 		PyObject *temp = self;
! 		self = PyObject_CallMethod(tzinfo, "fromutc",
! 					   "O", self);
! 		Py_DECREF(temp);
  	}
  	return self;