date-strings: Add date->mbox-string

This commit is contained in:
Jaidyn Ann 2022-11-17 21:17:01 -06:00
parent 7810eba236
commit bf84c6782a

View File

@ -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