-- Old code if'ed out, should be removed -- Originally, the first "Received:" header found was used to determine a "reliable" date. In my understanding, this ought to be the "last" one, as that is the "earliest" stamp and ought to be the one that best matches the requirements. Mbox.c adjusted to meet my understanding. It seems to work reliably, but further tests are required. Notes: Sun May 1 13:06:34 EDT 2005 rsc This patch isn't correct. The convention is that the message date is the arrival time not the sending time. In addition to breaking this convention, taking the innermost received means we have to figure out how to convert from that guy's time zone to our own, as it says in the comment. By the way, your patch also seemed to delete support for windows-1251 and koi8-r. Have you pulled recently? Russ Reference: /n/sources/patch/sorry/earliest-received Date: Sun May 1 07:54:17 CES 2005 Reviewed-by: rsc --- /sys/src/cmd/upas/fs/mbox.c Sun May 1 07:49:59 2005 +++ /sys/src/cmd/upas/fs/mbox.c Sun May 1 07:49:03 2005 @@ -292,6 +292,7 @@ s_free(m->unixdate); m->unixdate = nil; } +if(0){ // look for the date in the first Received: line. // it's likely to be the right time zone (it's // the local system) and in a convenient format. @@ -310,6 +311,25 @@ } } } +}else{ + char *hp = m->header; + while (cistrncmp(hp, "received:", 9)==0){ + if((q = strchr(hp, ';')) != nil){ + p = q; + while((p = strchr(p, '\n')) != nil){ + if(p[1] != ' ' && p[1] != '\t' && p[1] != '\n') + break; + p++; + } + } + hp = p; + } + if(p && *p=='\n'){ + *p = '\0'; + m->unixdate = date822tounix(q+1); + *p = '\n'; + } +} // fall back on the rfc822 date if(m->unixdate==nil && m->date822) @@ -1126,24 +1146,6 @@ len = 2*len + m->bend - m->body + 1; x = emalloc(len); len = windows1257toutf(x, m->body, m->bend); - if(m->ballocd) - free(m->body); - m->body = x; - m->bend = x + len; - m->ballocd = 1; - } - } else if(cistrcmp(s_to_c(m->charset), "windows-1251") == 0){ - len = xtoutf("cp1251", &x, m->body, m->bend); - if(len != 0){ - if(m->ballocd) - free(m->body); - m->body = x; - m->bend = x + len; - m->ballocd = 1; - } - } else if(cistrcmp(s_to_c(m->charset), "koi8-r") == 0){ - len = xtoutf("koi8", &x, m->body, m->bend); - if(len != 0){ if(m->ballocd) free(m->body); m->body = x;