diff options
author | Andrew Whatson | 2023-01-05 20:33:24 +1000 |
---|---|---|
committer | Arun Isaac | 2023-01-06 14:27:18 +0000 |
commit | aa6a58a152b8ebe0e786682ffd84239ed862dba4 (patch) | |
tree | b4146031c0c1b1c49b114ad3d3302c53545ce07a /email | |
parent | ca88c0899277a8e897538bda5b1bca2f2747cd61 (diff) | |
download | guile-email-aa6a58a152b8ebe0e786682ffd84239ed862dba4.tar.gz guile-email-aa6a58a152b8ebe0e786682ffd84239ed862dba4.tar.lz guile-email-aa6a58a152b8ebe0e786682ffd84239ed862dba4.zip |
email: Support Date fields with missing seconds.
* email/email.scm (parse-email-headers): Extend the date-time parser to
match when seconds are missing, defaulting to "0".
* tests/email.scm ("parse Date", "parse Date without seconds"): New
tests.
Signed-off-by: Arun Isaac <arunisaac@systemreboot.net>
Diffstat (limited to 'email')
-rw-r--r-- | email/email.scm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/email/email.scm b/email/email.scm index 71f0718..0d51eef 100644 --- a/email/email.scm +++ b/email/email.scm @@ -1,6 +1,7 @@ ;;; guile-email --- Guile email parser ;;; Copyright © 2018, 2019, 2020, 2021 Arun Isaac <arunisaac@systemreboot.net> ;;; Copyright © 2021 Mathieu Othacehe <othacehe@gnu.org> +;;; Copyright © 2023 Andrew Whatson <whatson@tailcall.au> ;;; ;;; This file is part of guile-email. ;;; @@ -1050,9 +1051,14 @@ list of header keys and values." (received-token . ,(match-lambda* (`(received-token ,token) token))) (date-time . ,(lambda node - (match-let - ((`((day ,day) (month ,month) (year ,year) - (hours ,hours) (minutes ,minutes) (seconds ,seconds) (zone . ,zone)) + (match-let* + (;; Seconds are optional; provide a default + ;; binding which will be shadowed by match. + (seconds "0") + ((('day day) ('month month) ('year year) + ('hours hours) ('minutes minutes) + . (or (('seconds seconds) ('zone . zone)) + (('zone . zone)))) (flatten-and-filter '(day month year hours minutes seconds zone) node))) |