From bf84c6782ace3e0f4e9dc5ba062f1a73c330e932 Mon Sep 17 00:00:00 2001 From: Jaidyn Levesque <10477760+JadedCtrl@users.noreply.github.com> Date: Thu, 17 Nov 2022 21:17:01 -0600 Subject: [PATCH] date-strings: Add date->mbox-string --- date-strings.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/date-strings.scm b/date-strings.scm index 607222f..b1d8681 100644 --- a/date-strings.scm +++ b/date-strings.scm @@ -20,7 +20,7 @@ ;; Some of these formats have dedicated output codes in srfi-19 (~c, ~x, etc), ;; but it looks like the chicken doesn't support them. (module date-strings - (date->rfc339-string rfc339-string->date date->rfc228-string) + (date->rfc339-string rfc339-string->date date->rfc228-string date->mbox-string) (import scheme (chicken condition) (chicken format) @@ -50,4 +50,11 @@ [timezone (if (string=? timezone-raw "Z") "+0000" timezone-raw)]) (format (date->string date "~~A, ~d ~~A ~Y ~T ~~A") weekday month timezone))) + +;; Converts a date into an mbox From-compatible string +(define (date->mbox-string date) + (let* ([month (string-titlecase (date->string date "~b"))] + [weekday (string-titlecase (date->string date "~a"))]) + (format (date->string date "~~A ~~A ~d ~T ~Y") weekday month))) + ) ;; date-strings module