summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2023-10-04 14:26:35 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2023-10-04 14:26:35 +0200
commit7c4253e84986c1edb0452c061fc50d706de119b5 (patch)
tree93696f0f7b24ee7a9bc97ede38ee6f1fd8185e6b /src
parent43a9f7ff957f8c314e5fae4dae9479ebd74ae4a5 (diff)
dates: move date formatting to dates
Diffstat (limited to 'src')
-rw-r--r--src/atom.scm9
-rw-r--r--src/dates.scm12
2 files changed, 13 insertions, 8 deletions
diff --git a/src/atom.scm b/src/atom.scm
index 229c032..fe4b9e7 100644
--- a/src/atom.scm
+++ b/src/atom.scm
@@ -3,7 +3,6 @@
#:use-module (src dates)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
- #:use-module (srfi srfi-19)
#:use-module (sxml simple)
#:use-module (ice-9 binary-ports)
#:use-module (rnrs bytevectors)
@@ -58,10 +57,6 @@
(email person-email)
(uri person-uri))
-(define zero-date (string/ISO->date "1970-01-01"))
-(define (newest a b) (if (time>? (date->time-utc a) (date->time-utc b)) a b))
-(define (find-newest dates) (reduce newest zero-date dates))
-
(define* (append-feed-entry! feed entry)
(let ((entries (feed-entries feed)))
(set-entry-id! entry (string-append
@@ -89,8 +84,8 @@
(define* (entry #:key (title "")
(id #f)
- (published zero-date)
- (updated zero-date)
+ (published unix-date)
+ (updated unix-date)
(authors '())
(summary-html '())
(content-html '())
diff --git a/src/dates.scm b/src/dates.scm
index edbac1c..2bbb977 100644
--- a/src/dates.scm
+++ b/src/dates.scm
@@ -1,10 +1,20 @@
(define-module (src dates)
+ #:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:export (string/ISO->date
- date->string/RFC3339))
+ date->string/RFC3339
+ unix-date
+ newest
+ find-newest))
(define (string/ISO->date string)
(string->date string "~Y-~m-~d"))
(define (date->string/RFC3339 date)
(date->string date "~4"))
+
+(define unix-date (string/ISO->date "1970-01-01"))
+
+(define (newest a b) (if (time>? (date->time-utc a) (date->time-utc b)) a b))
+
+(define (find-newest dates) (reduce newest unix-date dates))