Skip to content

Commit 6a803aa

Browse files
committed
Format dates in RSS feeds according to RFC 822
fixes #10
1 parent 04653d3 commit 6a803aa

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

blog/build/render/feed.rkt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
(content ([type "html"]) ,(xexpr->string `(article ,@body))))))]
3636

3737
['rss
38-
(define updated (post-date->string (rendered-post-date (first posts))))
38+
(define updated (post-date->rfc-822-date (rendered-post-date (first posts))))
3939
`(rss ([version "2.0"])
4040
(channel
4141
(title ,(index-page-title #:tag tag))
@@ -50,8 +50,17 @@
5050
(title ,title-str)
5151
(link ,(full-url (rendered-post-path post)))
5252
(guid ([isPermaLink "true"]) ,(full-url (rendered-post-path post)))
53-
(pubDate ,(post-date->string date))
53+
(pubDate ,(post-date->rfc-822-date date))
5454
(description ,(xexpr->string `(article ,@body)))))))]))
5555

5656
(define (post-date->rfc-3339-datetime date)
5757
(~a (post-date->string date) "T00:00:00Z"))
58+
59+
;; The RSS spec demands that dates be in this somewhat odd RFC 822 format, and
60+
;; this appears to be important for at least some actual RSS implementations;
61+
;; see lexi-lambda.github.io#10.
62+
(define (post-date->rfc-822-date date)
63+
(~a (~r (post-date-day date) #:min-width 2 #:pad-string "0")
64+
" " (vector-ref #("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
65+
(sub1 (post-date-month date)))
66+
" " (post-date-year date)))

0 commit comments

Comments
 (0)