Work on dates
This commit is contained in:
parent
20dba0c3d3
commit
11b20cb003
|
@ -42,7 +42,7 @@
|
||||||
,@(map
|
,@(map
|
||||||
(lambda (entries)
|
(lambda (entries)
|
||||||
`(section
|
`(section
|
||||||
(h2 ,(entry-us-english-date (first entries)))
|
(h2 ,(entry-english-year-and-month (first entries)))
|
||||||
,@(map (lambda (entry)
|
,@(map (lambda (entry)
|
||||||
`(article
|
`(article
|
||||||
(h3 ,(entry-title entry))
|
(h3 ,(entry-title entry))
|
||||||
|
|
64
planet.sld
64
planet.sld
|
@ -8,6 +8,7 @@
|
||||||
entry-content-xhtml
|
entry-content-xhtml
|
||||||
entry-iso-date
|
entry-iso-date
|
||||||
entry-us-english-date
|
entry-us-english-date
|
||||||
|
entry-english-year-and-month
|
||||||
planet-refresh-feed
|
planet-refresh-feed
|
||||||
planet-all-entries-ever
|
planet-all-entries-ever
|
||||||
planet-n-newest-entries
|
planet-n-newest-entries
|
||||||
|
@ -81,6 +82,21 @@
|
||||||
(define (path-append . paths)
|
(define (path-append . paths)
|
||||||
(string-join paths "/"))
|
(string-join paths "/"))
|
||||||
|
|
||||||
|
(define english-month-names
|
||||||
|
(vector
|
||||||
|
"January"
|
||||||
|
"February"
|
||||||
|
"March"
|
||||||
|
"April"
|
||||||
|
"May"
|
||||||
|
"June"
|
||||||
|
"July"
|
||||||
|
"August"
|
||||||
|
"September"
|
||||||
|
"October"
|
||||||
|
"November"
|
||||||
|
"December"))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define-record-type feed
|
(define-record-type feed
|
||||||
|
@ -112,34 +128,33 @@
|
||||||
(define (entry-content-xhtml entry)
|
(define (entry-content-xhtml entry)
|
||||||
(content-xhtml (entry-content entry)))
|
(content-xhtml (entry-content entry)))
|
||||||
|
|
||||||
(define (entry-iso-date entry)
|
(define (entry-rfc3339-digits n entry)
|
||||||
(let ((rfc3339 (entry-updated entry)))
|
(let ((rfc3339 (entry-updated entry)))
|
||||||
(if (and rfc3339 (>= (string-length rfc3339) 10))
|
(if (and rfc3339 (>= (string-length rfc3339) n))
|
||||||
(substring rfc3339 0 10)
|
(substring rfc3339 0 n)
|
||||||
(error "No date"))))
|
(error "No date"))))
|
||||||
|
|
||||||
(define (entry-us-english-date entry)
|
(define (entry-iso-date entry) (entry-rfc3339-digits 10 entry))
|
||||||
(define month-names
|
|
||||||
(vector
|
(define (entry-iso-month entry) (entry-rfc3339-digits 7 entry))
|
||||||
"January"
|
|
||||||
"February"
|
(define (entry-y-m-d-integers entry)
|
||||||
"March"
|
|
||||||
"April"
|
|
||||||
"May"
|
|
||||||
"June"
|
|
||||||
"July"
|
|
||||||
"August"
|
|
||||||
"September"
|
|
||||||
"October"
|
|
||||||
"November"
|
|
||||||
"December"))
|
|
||||||
(let* ((yyyy-mm-dd (entry-iso-date entry))
|
(let* ((yyyy-mm-dd (entry-iso-date entry))
|
||||||
(year (string->number (substring yyyy-mm-dd 0 4)))
|
(year (string->number (substring yyyy-mm-dd 0 4)))
|
||||||
(month (string->number (substring yyyy-mm-dd 5 7)))
|
(month (string->number (substring yyyy-mm-dd 5 7)))
|
||||||
(month-name (vector-ref month-names (- month 1)))
|
(day (string->number (substring yyyy-mm-dd 8 10))))
|
||||||
(day-of-month (string->number (substring yyyy-mm-dd 8 10))))
|
(values year month day)))
|
||||||
(string-append (number->string day-of-month) " "
|
|
||||||
month-name " " (number->string year))))
|
(define (entry-us-english-date entry)
|
||||||
|
(let-values (((year month day) (entry-y-m-d-integers entry)))
|
||||||
|
(let ((month-name (vector-ref english-month-names (- month 1))))
|
||||||
|
(string-append
|
||||||
|
(number->string day) " " month-name " " (number->string year)))))
|
||||||
|
|
||||||
|
(define (entry-english-year-and-month entry)
|
||||||
|
(let-values (((year month _) (entry-y-m-d-integers entry)))
|
||||||
|
(let ((month-name (vector-ref english-month-names (- month 1))))
|
||||||
|
(string-append month-name " " (number->string year)))))
|
||||||
|
|
||||||
(define (entry-iso-date<? entry1 entry2)
|
(define (entry-iso-date<? entry1 entry2)
|
||||||
(string<? (entry-iso-date entry1)
|
(string<? (entry-iso-date entry1)
|
||||||
|
@ -159,6 +174,9 @@
|
||||||
(define (planet-group-entries-by-date entries)
|
(define (planet-group-entries-by-date entries)
|
||||||
(group-by entry-iso-date entries))
|
(group-by entry-iso-date entries))
|
||||||
|
|
||||||
|
(define (planet-group-entries-by-month entries)
|
||||||
|
(group-by entry-iso-month entries))
|
||||||
|
|
||||||
(define (write-html-file filename sxml)
|
(define (write-html-file filename sxml)
|
||||||
(supersede-text-file
|
(supersede-text-file
|
||||||
filename (lambda ()
|
filename (lambda ()
|
||||||
|
|
Loading…
Reference in New Issue