diff -r 203d574c8a1d -r 08320697ca1a server/sqlutils.py --- a/server/sqlutils.py Fri Sep 30 18:10:28 2011 +0200 +++ b/server/sqlutils.py Tue Oct 04 12:23:52 2011 +0200 @@ -338,6 +338,17 @@ return _limit_size(text, maxsize) cnx.create_function("TEXT_LIMIT_SIZE", 2, limit_size2) + from logilab.common.date import strptime + def weekday(ustr): + try: + dt = strptime(ustr, '%Y-%m-%d %H:%M:%S') + except: + dt = strptime(ustr, '%Y-%m-%d') + # expect sunday to be 1, saturday 7 while weekday method return 0 for + # monday + return (dt.weekday() + 1) % 7 + cnx.create_function("WEEKDAY", 1, weekday) + import yams.constraints yams.constraints.patch_sqlite_decimal()