File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11from datetime import datetime
22import re
33
4+ try :
5+ # python 2
6+ _base_string_class = basestring
7+ except NameError :
8+ # python 3: no basestring class any more, everything is a str
9+ _base_string_class = str
10+
411# with thanks to https://code.google.com/p/jquery-localtime/issues/detail?id=4
512ISO_8601 = re .compile ("^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])"
613 "(T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?"
@@ -17,7 +24,7 @@ def timestamp_parameter(timestamp, allow_none=True):
1724 if isinstance (timestamp , datetime ):
1825 return timestamp .isoformat ()
1926
20- if isinstance (timestamp , basestring ):
27+ if isinstance (timestamp , _base_string_class ):
2128 if not ISO_8601 .match (timestamp ):
2229 raise ValueError ("Invalid timestamp: %s is not a valid ISO-8601 formatted date" % timestamp )
2330 return timestamp
You can’t perform that action at this time.
0 commit comments