Ticket #3044: util.py.diff
File util.py.diff, 993 bytes (added by , 18 years ago) |
---|
-
util.py
43 43 ############################################### 44 44 45 45 def typecast_date(s): 46 if isinstance(s, datetime.date): return s 46 47 return s and datetime.date(*map(int, s.split('-'))) or None # returns None if s is null 47 48 48 49 def typecast_time(s): # does NOT store time zone information 49 50 if not s: return None 51 if isinstance(s, datetime.time): return s 50 52 hour, minutes, seconds = s.split(':') 51 53 if '.' in seconds: # check whether seconds have a fractional part 52 54 seconds, microseconds = seconds.split('.') … … 58 60 # "2005-07-29 15:48:00.590358-05" 59 61 # "2005-07-29 09:56:00-05" 60 62 if not s: return None 63 if isinstance(s, datetime.datetime ): return s 61 64 if not ' ' in s: return typecast_date(s) 62 65 d, t = s.split() 63 66 # Extract timezone information, if it exists. Currently we just throw