diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-11-27 17:21:44 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-11-27 17:21:44 +0200 |
commit | 4eb3d0724550303cc27867112a167df7534ccb70 (patch) | |
tree | 0436c7ca94a503a1b6c8198cc0198c727090b7e5 | |
parent | cc9b15377689b27756597c32f32cd8ac89b84e72 (diff) | |
download | mailutils-4eb3d0724550303cc27867112a167df7534ccb70.tar.gz mailutils-4eb3d0724550303cc27867112a167df7534ccb70.tar.bz2 |
Improve mbox data/time handling
* libproto/mbox/mboxrb.c (scan_message_begin): Use a single scan
format for parsing all possible variants of the date/time.
-rw-r--r-- | libproto/mbox/mboxrb.c | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/libproto/mbox/mboxrb.c b/libproto/mbox/mboxrb.c index a64a5f1ce..78b9664a5 100644 --- a/libproto/mbox/mboxrb.c +++ b/libproto/mbox/mboxrb.c @@ -533,47 +533,11 @@ scan_message_begin (struct mu_mboxrb_mailbox *dmp, mu_stream_t stream, * a normalized form (ctime(3)). */ struct tm tm; - char const *fmt; + static char const fmt[] = "%a %b %e %H:%M%[:%S%] %(%Z %Y%|%Y%[ %Z%]%)"; struct mu_timezone tz; char *te; time_t t; - int numeric_zone = zn[1] == '+' || zn[1] == '-' || mu_isdigit (zn[1]); - if (zn[-3] == ':') - { - if (zn[-6] == ':') - { - if (numeric_zone) - fmt = "%a %b %e %H:%M:%S %z %Y"; - else - fmt = "%a %b %e %H:%M:%S %Z %Y"; - } - else - { - if (numeric_zone) - fmt = "%a %b %e %H:%M %z %Y"; - else - fmt = "%a %b %e %H:%M %Z %Y"; - } - } - else - { - if (zn[-11] == ':') - { - if (numeric_zone) - fmt = "%a %b %e %H:%M:%S %Y %z"; - else - fmt = "%a %b %e %H:%M:%S %Y %Z"; - } - else - { - if (numeric_zone) - fmt = "%a %b %e %H:%M %Y %z"; - else - fmt = "%a %b %e %H:%M %Y %Z"; - } - } - if (mu_scan_datetime (ti - 10, fmt, &tm, &tz, &te) == 0) t = mu_datetime_to_utc (&tm, &tz); else |