This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients heidar.rafn, vstinner
Date 2011-09-02.14:54:18
SpamBayes Score 0.026015706
Marked as misclassified No
Message-id <1314975259.12.0.675192176707.issue12886@psf.upfronthosting.co.za>
In-reply-to
Content
Example:
---
import datetime

def test(text):
    try:
        d = datetime.datetime.strptime(text, '%Y%m%dT%H%M')
    except ValueError:
        pass
    else:
        print("%s without seconds => %s" % (text, d))
        return
    d = datetime.datetime.strptime(text, '%Y%m%dT%H%M%S')
    print("%s with seconds => %s" % (text, d))

test('20110817T1234')
test('20110817T12345')
test('20110817T123456')
---

Output:

20110817T1234 without seconds => 2011-08-17 12:34:00
20110817T12345 with seconds => 2011-08-17 12:34:05
20110817T123456 with seconds => 2011-08-17 12:34:56
History
Date User Action Args
2011-09-02 14:54:19vstinnersetrecipients: + vstinner, heidar.rafn
2011-09-02 14:54:19vstinnersetmessageid: <1314975259.12.0.675192176707.issue12886@psf.upfronthosting.co.za>
2011-09-02 14:54:18vstinnerlinkissue12886 messages
2011-09-02 14:54:18vstinnercreate