diff options
author | June McEnroe <june@causal.agency> | 2020-04-13 13:13:37 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-04-13 13:13:37 -0400 |
commit | 77dc80bbbe942eef0453fc1e3b7782a2ddf29879 (patch) | |
tree | 5a1518ce9772429b13c08d6cd9d406c01224c39e | |
parent | Use UTC date everywhere (diff) | |
download | bubger-77dc80bbbe942eef0453fc1e3b7782a2ddf29879.tar.gz bubger-77dc80bbbe942eef0453fc1e3b7782a2ddf29879.zip |
Preserve original Date header in envelope
Diffstat (limited to '')
-rw-r--r-- | archive.h | 3 | ||||
-rw-r--r-- | atom.c | 2 | ||||
-rw-r--r-- | html.c | 9 | ||||
-rw-r--r-- | parse.c | 14 |
4 files changed, 16 insertions, 12 deletions
diff --git a/archive.h b/archive.h index 0dac623..9ea15f4 100644 --- a/archive.h +++ b/archive.h @@ -40,7 +40,8 @@ struct AddressList { }; struct Envelope { - time_t date; + time_t time; + const char *date; char *subject; struct Address from, sender, replyTo; struct AddressList to, cc, bcc; diff --git a/atom.c b/atom.c index aa98406..98f5866 100644 --- a/atom.c +++ b/atom.c @@ -33,7 +33,7 @@ static char *atomID(const char *messageID) { int atomEntryOpen(FILE *file, const struct Envelope *envelope) { char *id = atomID(envelope->messageID); char date[sizeof("0000-00-00T00:00:00Z")]; - strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->date)); + strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->time)); struct Variable vars[] = { { "subject", envelope->subject }, { "from.name", addressName(envelope->from) }, diff --git a/html.c b/html.c index 808e799..1d28541 100644 --- a/html.c +++ b/html.c @@ -89,15 +89,16 @@ int htmlMessageHead(FILE *file, const struct Envelope *envelope) { ); char *mbox = templateURL("../message/[pathID].mbox", urlVars); - char date[sizeof("0000-00-00T00:00:00Z")]; - strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->date)); + char utc[sizeof("0000-00-00T00:00:00Z")]; + strftime(utc, sizeof(utc), "%FT%TZ", gmtime(&envelope->time)); struct Variable vars[] = { { "messageID", envelope->messageID }, { "fragment", fragment }, { "subject", envelope->subject }, { "mailto", mailto }, { "from", addressName(envelope->from) }, - { "date", date }, + { "date", envelope->date }, + { "utc", utc }, { "mbox", mbox }, {0}, }; @@ -106,7 +107,7 @@ int htmlMessageHead(FILE *file, const struct Envelope *envelope) { <summary> <a class="subject" href="[fragment]">[subject]</a> <address class="from"><a href="[mailto]">[from]</a></address> - <time datetime="[date]">[date]</time> + <time datetime="[utc]">[date]</time> <a class="mbox" href="[mbox]">mbox</a> </summary> ); diff --git a/parse.c b/parse.c index 8d3205d..ff97789 100644 --- a/parse.c +++ b/parse.c @@ -66,20 +66,22 @@ void parseEnvelope(struct Envelope *envelope, struct List list) { errx(EX_PROTOCOL, "missing envelope structure fields"); } - struct tm tm; + + struct tm time; const char *date = dataCheck(list.ptr[Date], String).string; + envelope->date = date; if (isalpha(date[0])) { - date = strptime(date, "%a, %e %b %Y %H:%M:%S ", &tm); + date = strptime(date, "%a, %e %b %Y %H:%M:%S ", &time); } else { - date = strptime(date, "%e %b %Y %H:%M:%S ", &tm); + date = strptime(date, "%e %b %Y %H:%M:%S ", &time); } if (date && (date[0] == '+' || date[0] == '-')) { - date = strptime(date, "%z", &tm); + date = strptime(date, "%z", &time); } else if (date) { - date = strptime(date, "%Z", &tm); + date = strptime(date, "%Z", &time); } if (!date) errx(EX_PROTOCOL, "invalid envelope date format"); - envelope->date = mktime(&tm); + envelope->time = mktime(&time); // TODO: Decode UTF-8 in subject. envelope->subject = strdup(dataCheck(list.ptr[Subject], String).string); |