Skip to content
Snippets Groups Projects
Commit b5d6f162 authored by Cam Saul's avatar Cam Saul
Browse files

Merge branch 'master' into ag-test-wrap-sessionid

parents 55e1e0c6 f260b0c7
No related branches found
No related tags found
No related merge requests found
......@@ -36,8 +36,8 @@
(-> (ins Annotation
:organization_id organization
:author_id *current-user-id*
:start (util/parse-iso8601-with-ms start)
:end (util/parse-iso8601-with-ms end)
:start (util/parse-iso8601 start)
:end (util/parse-iso8601 end)
:title title
:body body
:annotation_type annotation_type
......
......@@ -5,6 +5,11 @@
(declare -format-response)
;; # SHADY HACK
;; Tell the JSON middleware to use a date format that includes milliseconds
(intern 'cheshire.factory 'default-date-format "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
;; # FORMAT RESPONSE MIDDLEWARE
(defn format-response
"Middleware that recurses over Clojure object before it gets converted to JSON and makes adjustments neccessary so the formatter doesn't barf.
e.g. functions and delays are stripped and H2 Clobs are converted to strings."
......
......@@ -88,32 +88,21 @@
(Some DBs like Postgres will get snippy if you don't use a `java.sql.Timestamp`)."
[]
(-> (java.util.Date.)
.getTime ; time in milliseconds
(/ 1000) ; we don't care about the ms so strip them out
int
(* 1000)
.getTime
(java.sql.Timestamp.)))
(defn parse-iso8601
"parse a string value expected in the iso8601 format into a `java.sql.Date`."
[datetime]
(some->> datetime
(time/parse (time/formatters :date-time-no-ms))
(time/parse (time/formatters :date-time))
(coerce/to-long)
(java.sql.Date.)))
(defn parse-iso8601-with-ms
"parse a string value expected in the iso8601 format WITH MILLISECONDS into a `java.sql.Date`."
[datetime]
(some->> datetime
(time/parse (time/formatters :date-time))
(coerce/to-long)
(java.sql.Date.)))
(defn now-iso8601
"format the current time as iso8601 date/time string."
[]
(time/unparse (time/formatters :date-time-no-ms) (coerce/from-long (System/currentTimeMillis))))
(time/unparse (time/formatters :date-time) (coerce/from-long (System/currentTimeMillis))))
(defn jdbc-clob->str
"Convert a `JdbcClob` to a `String`."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment