Changeset 346
- Timestamp:
- 07/29/05 16:10:09 (3 years ago)
- Files:
-
- django/trunk/django/core/db/typecasts.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/db/typecasts.py
r3 r346 10 10 def typecast_time(s): # does NOT store time zone information 11 11 if not s: return None 12 bits = s.split(':')13 if len(bits[2].split('.')) > 1: # if there is a decimal (e.g. '11:16:36.181305')14 return datetime.time(int(bits[0]), int(bits[1]), int(bits[2].split('.')[0]),15 int(bits[2].split('.')[1].split('-')[0]))16 else: # no decimal was found (e.g. '12:30:00')17 return datetime.time(int(bits[0]), int(bits[1]), int(bits[2].split('.')[0]), 0)12 hour, minutes, seconds = s.split(':') 13 if '.' in seconds: # check whether seconds have a fractional part 14 seconds, microseconds = seconds.split('.') 15 else: 16 microseconds = '0' 17 return datetime.time(int(hour), int(minutes), int(seconds), int(microseconds)) 18 18 19 19 def typecast_timestamp(s): # does NOT store time zone information 20 # "2005-07-29 15:48:00.590358-05" 21 # "2005-07-29 09:56:00-05" 20 22 if not s: return None 21 23 d, t = s.split() 24 if t[-3] in ('-', '+'): 25 t = t[:-3] # Remove the time-zone information, if it exists. 22 26 dates = d.split('-') 23 27 times = t.split(':') … … 28 32 microseconds = '0' 29 33 return datetime.datetime(int(dates[0]), int(dates[1]), int(dates[2]), 30 int(times[0]), int(times[1]), int(seconds.split('-')[0]), 31 int(microseconds.split('-')[0])) 34 int(times[0]), int(times[1]), int(seconds), int(microseconds)) 32 35 33 36 def typecast_boolean(s):
