[Patches] [ python-Patches-1100942 ] datetime.strptime constructor added

SourceForge.net noreply at sourceforge.net
Tue Jan 25 13:05:44 CET 2005


Patches item #1100942, was opened at 2005-01-13 01:53
Message generated for change (Comment added) made by alanvgreen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1100942&group_id=5470

Category: Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
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: Alan Green (alanvgreen)
Date: 2005-01-25 23: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


More information about the Patches mailing list