Datetime formats

0 views
Skip to first unread message

Etienne Robillard

unread,
May 19, 2009, 9:10:13 PM5/19/09
to sch...@googlegroups.com

Hi,

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

field-datetime.patch

Matthew Scott

unread,
Jun 7, 2009, 9:03:23 PM6/7/09
to sch...@googlegroups.com
Etienne,

Could you describe the use case you have for needing a f.datetime() field to store either a datetime or a date, rather than using the f.date() field type to store dates without times?

Thanks,
--
Matthew R. Scott

erob

unread,
Jun 8, 2009, 2:04:47 PM6/8/09
to Schevo
Hi Matthew,

I forgot mentioning that an updated patch exist.

http://joelia.gthc.org/schevo/rev/bbddf6ab527c

This patch should be more acceptable. At least I use
it to properly displaying date fields in a cell using
a proper date(time) formatting. I admit thought that
the first patch was probably incomplete/not functional.

Btw, I added 2 more Hg repositories for Schevo on joelia.gthc.org:

http://joelia.gthc.org/schevo-gtk/
http://joelia.gthc.org/schevo/

Best regards,
Etienne

Matthew Scott

unread,
Jun 8, 2009, 2:08:58 PM6/8/09
to sch...@googlegroups.com
On Mon, Jun 8, 2009 at 11:04, erob <robillar...@gmail.com> wrote:

Hi Matthew,

I forgot mentioning that an updated patch exist.

http://joelia.gthc.org/schevo/rev/bbddf6ab527c

OK, I'll take a look at this soon.

 
Btw, I added 2 more Hg repositories for Schevo on joelia.gthc.org:

http://joelia.gthc.org/schevo-gtk/
http://joelia.gthc.org/schevo/

You are of course free to do whatever you like with regards to hosting your own repositories, but it would be much easier to track what you are doing, as well as merge in changes to the main repository, if you made a clone of schevo and schevogtk on github.com.

I've cloned other repositories on github.com and bitbucket.org to make small changes or fixes, and the workflow used by those sites works pretty well.

You can even use Mercurial as your local interface to work with your clone:  http://github.com/blog/439-hg-git-mercurial-plugin


--
Matthew R. Scott

erob

unread,
Jun 25, 2009, 9:57:19 AM6/25/09
to Schevo
Hi Matthew et al,

I tried using hg-git... It looks certainly promising, but there's a
few bugs that
prevent me from fully using it. Still I bet that this plugin will
improve in
later releases.. ;-)

On another story, I have a question for Schevo/SchevoGtk2 developers.
I'd like
adding some new widgets in SchevoGtk2. Would you like to explain
briefly how
to add things like radio-buttons, etc ?

Moreover, can this be done only in SchevoGtk2 or should this kind of
extensions needs
adding new field types in the core Schevo package ?

Best regards,
Etienne





On 8 juin, 14:08, Matthew Scott <gldns...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages