#223 DateCols break for years <1000 on SQLite

closed-fixed
Oleg Broytman
SQLite (24)
5
2007-07-20
2007-07-20
Anonymous
No

I'm using SQLObject 0.9.0 with a SQLite database. If I have the schema:

class Test(SQLObject):
val = DateCol()

and try to create an instance with the year < 1000:

x = Test(val=date(900, 2, 1))

I get an exception:

formencode.api.Invalid: expected a date/time string of the '%Y-%m-%d' format in the DateTimeCol 'val', got <type 'str'> ' 900-02-01' instead

I traced this to converters.py; on my Ubuntu 7.04 system, at least, time.strftime requires leading zeros for %Y, while the DateTimeConverter and DateConverter generate the year with the format string %4d.

Changing the two format strings to use %04d fixed the bug for me.

Discussion

  • Oleg Broytman
    Oleg Broytman
    2007-07-20

    Logged In: YES
    user_id=4799
    Originator: NO

    Fixed in the revisions 2773-2777 (branches 0.7, 0.8, 0.9, the trunk and docs.) Thank you!

     
  • Oleg Broytman
    Oleg Broytman
    2007-07-20

    • assigned_to: nobody --> phd
    • status: open --> closed-fixed