I added a patch in schevo/field.py to support
slightly better datetime/date formats. Also, I modified the get()
method to return a 'datetime.date' object for a 3-items tuple value,
in addition to the default (7-items tuple) value.
Kind Regards,
Etienne
diff --git a/schevo/field.py b/schevo/field.py
index 0d6d72e..c72e430 100644
--- a/schevo/field.py
+++ b/schevo/field.py
@@ -945,6 +945,7 @@ class Datetime(Field):
self.format,
'%Y-%m-%d %H:%M:%S',
'%Y-%m-%d %H:%M',
+ '%Y-%m-%d',
'%Y%m%d%H%M%S',
'%m/%d/%Y %H:%M:%S',
'%m/%d/%Y %H:%M',
@@ -974,12 +975,19 @@ class Datetime(Field):
return self._value
def get(self):
- v = Field.get(self)
- if isinstance(v, tuple):
- year, month, day, hour, minute, second, microsecond = v
- v = datetime.datetime(year, month, day, hour, minute,
+ value = Field.get(self)
+ if isinstance(value, tuple):
+ if len(value) == 7:
+ year, month, day, hour, minute, second, microsecond =
value
+ value = datetime.datetime(year, month, day, hour,
minute, second, microsecond)
- return v
+ elif len(value) == 3:
+ year, month, day = value
+ value = datetime.date(year, month, day)
+ else:
+ raise ValueError("Unexpected tuple size: %d" %
len(value)) +
+ return value
get_immutable = get
Hi Matthew,
I forgot mentioning that an updated patch exist.
http://joelia.gthc.org/schevo/rev/bbddf6ab527c
Btw, I added 2 more Hg repositories for Schevo on joelia.gthc.org:
http://joelia.gthc.org/schevo-gtk/
http://joelia.gthc.org/schevo/