Ticket #3044: util.py.diff

File util.py.diff, 993 bytes (added by cephelo@…, 18 years ago)

django\db\backends\util.py patch

  • util.py

     
    4343###############################################
    4444
    4545def typecast_date(s):
     46    if isinstance(s, datetime.date): return s
    4647    return s and datetime.date(*map(int, s.split('-'))) or None # returns None if s is null
    4748
    4849def typecast_time(s): # does NOT store time zone information
    4950    if not s: return None
     51    if isinstance(s, datetime.time): return s
    5052    hour, minutes, seconds = s.split(':')
    5153    if '.' in seconds: # check whether seconds have a fractional part
    5254        seconds, microseconds = seconds.split('.')
     
    5860    # "2005-07-29 15:48:00.590358-05"
    5961    # "2005-07-29 09:56:00-05"
    6062    if not s: return None
     63    if isinstance(s, datetime.datetime ): return s
    6164    if not ' ' in s: return typecast_date(s)
    6265    d, t = s.split()
    6366    # Extract timezone information, if it exists. Currently we just throw
Back to Top