[Zope-dev] ZMailIn patch (index 'date' as DateTime object)

Jean Jordaan jean@upfrontsystems.co.za
Fri, 9 Nov 2001 12:08:51 +0200


Hi Andy & all

There I was, trying to select last week's mail messages from
the ZMailInCatalog, when I realized that the 'date' index was
a simple string. 

Here's a patch, adding a property 'datetime', which can be 
used as an index of type DateTime. 

Anything I'm missing here? In particular, I'm not sure I
understand what 'sortableDate' is meant for. It's a string 
like this::

  str('%04d%02d%02d%02d%02d%02d' % (dateTuple[0],dateTuple[1],
      dateTuple[2],dateTuple[3],dateTuple[4],dateTuple[5]))

But it's still a string, and can't be used in comparisons 
with DateTimes. Why not just use 'datetime', also sortable?

Regards,
Jean Jordaan

[jean@blommie ZMailIn]$ diff -u ./ZMailMessage.py ./ZMailMessage_hacked.py 
--- ./ZMailMessage.py  Tue Mar  6 12:33:03 2001
+++ ./ZMailMessage_hacked.py    Fri Nov  9 11:42:32 2001
@@ -61,6 +61,9 @@
         self.subject = subject
         self.date = date
         self.sortableDate = self._convertToSortableDate(date)
+        # njj: index the date as a date.
+        import DateTime
+        self.datetime = DateTime.DateTime(date) 
         self.to = to
         self.sender = sender
         self.replyto = replyto