#178 Regression in DateTimeValidator

closed-fixed
Oleg Broytman
General (126)
5
2006-06-14
2006-05-28
Markus Gritsch
No

The following change in the class DateTimeValidator
leads to different return values:

SQLObject-0.7.0:
secs = time.mktime(stime)
return datetime.datetime.fromtimestamp(secs)

SQLObject-0.7.1b1:
return datetime.datetime(*stime[:7])

I think only the first 6 items of stime should be used
instead of also including the microseconds. When I
change the line to
return datetime.datetime(*stime[:6])
everything works fine again.

Discussion

  • Markus Gritsch
    Markus Gritsch
    2006-06-04

    Logged In: YES
    user_id=553904

    Additional note: The 7th value is not the micro-seconds, but
    the day-of-the-week. So the line should be definitely
    changed to the one I suggested.

     
  • Oleg Broytman
    Oleg Broytman
    2006-06-07

    Logged In: YES
    user_id=4799

    Can you write a short test script that demonstrates the problem?

     
  • Oleg Broytman
    Oleg Broytman
    2006-06-07

    • assigned_to: nobody --> phd
     
  • Oleg Broytman
    Oleg Broytman
    2006-06-07

    Logged In: YES
    user_id=4799

    Can you write a short test script that demonstrates the problem?

     
  • Markus Gritsch
    Markus Gritsch
    2006-06-12

    Logged In: YES
    user_id=553904

    Since the 7th item of stime is the day-of-the-week, the
    script below prints out
    2006-06-11 00:00:00.000006
    wrongly taking the 6th day-of-the-week as the microseconds.

    ---

    import datetime
    from sqlobject import *

    sqlhub.processConnection = connectionForURI('sqlite:/:memory:')

    class Test(SQLObject):
    time = DateTimeCol()

    Test.createTable()

    t = Test(time=datetime.datetime(2006, 6, 11))

    print Test.selectBy(id=1)[0].time

     
  • Oleg Broytman
    Oleg Broytman
    2006-06-14

    Logged In: YES
    user_id=4799

    Applied in the revision 1809 to the trunk. Thank you!

     
  • Oleg Broytman
    Oleg Broytman
    2006-06-14

    • status: open --> closed-fixed