Ticket #12059: 12059.diff

File 12059.diff, 1.4 KB (added by simonz05, 5 years ago)
  • django/db/models/fields/__init__.py

     
    835835            # Not usually a good idea to pass in a datetime here (it loses
    836836            # information), but this can be a side-effect of interacting with a
    837837            # database backend (e.g. Oracle), so we'll be accommodating.
    838             return value.time
     838            return value.time()
    839839
    840840        # Attempt to parse a datetime:
    841841        value = smart_str(value)
  • tests/regressiontests/datatypes/models.py

     
    5858>>> d3.consumed_at
    5959datetime.datetime(2007, 4, 20, 16, 19, 59)
    6060
     61# Test for ticket #12059: TimeField wrongly handling datetime.datetime object.
     62
     63>>> d2.baked_time = datetime.datetime(year=2007, month=4, day=20, hour=16, minute=19, second=59)
     64>>> d2.save()
     65
     66>>> d3 = Donut.objects.all()[0]
     67>>> d3.baked_time
     68datetime.time(16, 19, 59)
     69
    6170# Year boundary tests (ticket #3689)
    6271
    6372>>> d = Donut(name='Date Test 2007', baked_date=datetime.datetime(year=2007, month=12, day=31), consumed_at=datetime.datetime(year=2007, month=12, day=31, hour=23, minute=59, second=59))
Back to Top