Skip to content

Commit 7b9ca20

Browse files
authored
Merge pull request #7 from clojure-emacs/print-uuid-inst
Add print handler for #uuid and #inst
2 parents 90cfe3d + 5470d4e commit 7b9ca20

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Added
44

5+
- Added print handler for `#uuid` and `#inst`
6+
57
## Fixed
68

79
## Changed

parseedn.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ TAG-READERS is an optional association list. For more information, see
162162
(insert ", ")
163163
(parseedn-print-plist next))))
164164

165+
(defun parseedn-print-inst (time)
166+
"Insert an inst value into the current buffer.
167+
168+
Take an encode-time style value and print it as a timestamp
169+
deliniated by double quotes."
170+
(insert (format-time-string "\"%Y-%m-%dT%T\"" time)))
171+
165172
(defun parseedn-alist-p (list)
166173
"Non-null if and only if LIST is an alist with simple keys."
167174
(while (consp list)
@@ -224,6 +231,10 @@ DATUM can be any Emacs Lisp value."
224231
(error "Don't know how to print: %s" datum))
225232
((eq 'edn-set (car datum))
226233
(insert "#{") (parseedn-print-seq (cadr datum)) (insert "}"))
234+
((eq 'edn-uuid (car datum))
235+
(insert "#uuid ") (parseedn-print-seq (cdr datum)))
236+
((eq 'edn-inst (car datum))
237+
(insert "#inst ") (parseedn-print-inst (cdr datum)))
227238
(t (insert "(") (parseedn-print-seq datum) (insert ")"))))
228239

229240
(t (error "Don't know how to print: %s" datum))))

test/parseedn-test-data.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,17 @@
340340
"booleans"
341341
(a-list
342342
:source "[nil true false]"
343-
:edn '([nil t nil]))))
343+
:edn '([nil t nil]))
344+
345+
"uuid"
346+
(a-list
347+
:source "#uuid \"c9c4eac2-7b23-4d62-a444-41a72dc09039\""
348+
:edn '((edn-uuid "c9c4eac2-7b23-4d62-a444-41a72dc09039")))
349+
350+
"inst"
351+
(a-list
352+
:source "#inst \"2020-09-09T06:56:04\""
353+
;; FIXME this value may differ depending on the timezone of your machine
354+
:edn '((edn-inst 24408 31876)))))
344355

345356
;;; parseedn-test-data.el ends here

0 commit comments

Comments
 (0)