--- a/server/sqlutils.py Mon Sep 26 18:37:23 2011 +0200
+++ b/server/sqlutils.py Fri Dec 09 12:08:27 2011 +0100
@@ -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()