* IMAP date strings. More stupidity.
[citadel.git] / citadel / imap_fetch.c
index 5b3c457ac58d8120aadb0ce2d9b0722767ac5396..a85eba79ffd28f3254379413d0a51bb46dcb4505 100644 (file)
@@ -39,6 +39,7 @@
 #include "serv_imap.h"
 #include "imap_tools.h"
 #include "imap_fetch.h"
+#include "genstamp.h"
 
 
 
@@ -52,6 +53,21 @@ void imap_fetch_uid(int seq) {
        cprintf("UID %ld", IMAP->msgids[seq-1]);
 }
 
+void imap_fetch_internaldate(struct CtdlMessage *msg) {
+       char buf[256];
+       time_t msgdate;
+
+       if (msg->cm_fields['T'] != NULL) {
+               msgdate = atol(msg->cm_fields['T']);
+       }
+       else {
+               msgdate = time(NULL);
+       }
+
+       datestring(buf, msgdate, DATESTRING_IMAP);
+       cprintf("INTERNALDATE \"%s\"", buf);
+}
+
 
 /*
  * imap_do_fetch() calls imap_do_fetch_msg() to output the deta of an
@@ -81,7 +97,7 @@ void imap_do_fetch_msg(int seq, struct CtdlMessage *msg,
                        /* FIXME do something here */
                }
                else if (!strcasecmp(itemlist[i], "INTERNALDATE")) {
-                       /* FIXME do something here */
+                       imap_fetch_internaldate(msg);
                }
                else if (!strcasecmp(itemlist[i], "RFC822")) {
                        /* FIXME do something here */