diff options
author | June McEnroe <june@causal.agency> | 2020-04-13 12:43:56 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-04-13 12:43:56 -0400 |
commit | d031cf5f00de4bf6b33396f1a448833a6de33c5f (patch) | |
tree | aa80e5cda92bfc2d3338f7020a8ab75ca1369cf5 /parse.c | |
parent | Rework path functions again (diff) | |
download | bubger-d031cf5f00de4bf6b33396f1a448833a6de33c5f.tar.gz bubger-d031cf5f00de4bf6b33396f1a448833a6de33c5f.zip |
Use UTC date everywhere
I thought I could preserve the original time zone but it turns out that libc is just too shit to do that.
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/parse.c b/parse.c index 6f1a56b..8d3205d 100644 --- a/parse.c +++ b/parse.c @@ -66,21 +66,20 @@ void parseEnvelope(struct Envelope *envelope, struct List list) { errx(EX_PROTOCOL, "missing envelope structure fields"); } + struct tm tm; const char *date = dataCheck(list.ptr[Date], String).string; if (isalpha(date[0])) { - date = strptime(date, "%a, %e %b %Y %H:%M:%S ", &envelope->date); + date = strptime(date, "%a, %e %b %Y %H:%M:%S ", &tm); } else { - date = strptime(date, "%e %b %Y %H:%M:%S ", &envelope->date); + date = strptime(date, "%e %b %Y %H:%M:%S ", &tm); } if (date && (date[0] == '+' || date[0] == '-')) { - date = strptime(date, "%z", &envelope->date); + date = strptime(date, "%z", &tm); } else if (date) { - date = strptime(date, "%Z", &envelope->date); + date = strptime(date, "%Z", &tm); } if (!date) errx(EX_PROTOCOL, "invalid envelope date format"); - - envelope->date.tm_isdst = -1; - envelope->utc = mktime(&envelope->date); + envelope->date = mktime(&tm); // TODO: Decode UTF-8 in subject. envelope->subject = strdup(dataCheck(list.ptr[Subject], String).string); |