mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Add strptime() constructor to datetime class. Thanks to Josh Spoerri for
the changes.
This commit is contained in:
parent
2f8c6589f5
commit
0af3ade6aa
5 changed files with 66 additions and 0 deletions
|
@ -1421,6 +1421,15 @@ class TestDateTime(TestDate):
|
|||
# Else try again a few times.
|
||||
self.failUnless(abs(from_timestamp - from_now) <= tolerance)
|
||||
|
||||
def test_strptime(self):
|
||||
import time
|
||||
|
||||
string = '2004-12-01 13:02:47'
|
||||
format = '%Y-%m-%d %H:%M:%S'
|
||||
expected = self.theclass(*(time.strptime(string, format)[0:6]))
|
||||
got = self.theclass.strptime(string, format)
|
||||
self.assertEqual(expected, got)
|
||||
|
||||
def test_more_timetuple(self):
|
||||
# This tests fields beyond those tested by the TestDate.test_timetuple.
|
||||
t = self.theclass(2004, 12, 31, 6, 22, 33)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue