From 7e2150f81cfe3763ce82290a0e9c61e420898ef0 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sat, 15 Jan 2011 13:34:23 +0000 Subject: [PATCH] provide date/time parsing for Python 2.4 git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@4144 fd906abe-77d9-0310-91a1-e0d9ade77398 --- util/date.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/date.py b/util/date.py index 59b4065..5613747 100644 --- a/util/date.py +++ b/util/date.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2009 Helmut Merz helmutm@cy55.de +# Copyright (c) 2011 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ $Id$ """ import time +from datetime import datetime def getTimeStamp(): @@ -51,3 +52,6 @@ def str2timeStamp(s): t = time.strptime(s, '%Y-%m-%d') return int(time.mktime(t)) + +def strptime(s, format='%Y-%m-%d %H:%M:%S'): + return datetime(*(time.strptime(s, format)[:6]))