Patches item #1100942, was opened at 2005-01-12 15:53 Message generated for change (Comment added) made by sonderblade You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1100942&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Modules Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Josh (josh-sf) Assigned to: Nobody/Anonymous (nobody) Summary: datetime.strptime constructor added Initial Comment: Alllow creating new datetime objects by parsing date strings. datetime already has strftime, so adding strptime is logical. The new constructor is equivalent to datetime(*(time.strptime(date_string, format)[0:6])). Patch includes documentation and unit test. ---------------------------------------------------------------------- Comment By: Bj�rn Lindqvist (sonderblade) Date: 2007-06-05 22:44 Message: Logged In: YES user_id=51702 Originator: NO The patch doesn't apply cleanly anymore, although that was easy to fix. With the patch, I also get a few implicit declaration warnings and a few conflicting type errors. Rearranging the order of the functions solve that. Fixing that makes the code compile. The two new methods seem to work correct, although there should be unit tests. ---------------------------------------------------------------------- Comment By: Josh (josh-sf) Date: 2005-02-17 18:15 Message: Logged In: YES user_id=1194964 The first patch has been applied, now just the second needs to be. (strptime2.diff). That adds support for date and time as well as datetime, as per alanvgreen's suggestion. ---------------------------------------------------------------------- Comment By: Josh (josh-sf) Date: 2005-02-02 01:50 Message: Logged In: YES user_id=1194964 Regarding support by datetime.time and datetime.date, if a date component or a time component is specified, respectively, do you think that we should raise an exception? or should we just ignore it? ---------------------------------------------------------------------- Comment By: Alan Green (alanvgreen) Date: 2005-01-25 13:05 Message: Logged In: YES user_id=1174944 This patch will be welcomed by all of that have had to write "datetime(*(time.strptime(date_string, format)[0:6]))". I don't understand the C API well enough to check if reference counts are handled properly, but otherwise the implementation looks straight forward. Documentation looks good and the test passes on my machine. Two suggestions: 1. In the time module, the strptime() function's format parameter is optional. For consistency's sake, I'd expect datetime.strptime()'s format parameter also to be optional. (On the other hand, the default value for the format is not very useful.) 2. Since strftime is supported by datetime.time, datetime.date and datetime.datetime, I'd also expect strptime to be supported by all three classes. Could you add that now, or would it be better to do it as a separate patch? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1100942&group_id=5470
_______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches