Skip to content

Commit

Permalink
Teach awyeah-api to handle ISO8601 timestamps with microsecond precision
Browse files Browse the repository at this point in the history
This is a divergence from aws-api. The aws-api uses
java.text.SimpleDateFormat for timestamp parsing, and is unable to
parse timestamps with precision greater than milliseconds. (Attempting
to do so silently corrupts the timestamp. See aws-api commit
636a7af35b6f11c3b26eaa9aa47067ac5b312b20 for an example.)

awyeah-api uses java.time.format.DateTimeFormatter, which can parse
timestamps with up to nanosecond precision. We likely only need
microsecond precision given the samples I've seen, so add a formatter
than handles microsecond-precision ISO8601 timestamps.
  • Loading branch information
grzm committed Nov 12, 2023
1 parent 849d133 commit 2ac9da4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/com/grzm/awyeah/shape.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
(= "iso8601" timestampFormat)
(parse-date* data
util/iso8601-date-format
util/iso8601-msecs-date-format)
util/iso8601-msecs-date-format
util/iso8601-usecs-date-format)
(int? data)
(java.util.Date. (* 1000 ^int data))
(double? data)
Expand All @@ -104,6 +105,7 @@
(parse-date* data
util/iso8601-date-format
util/iso8601-msecs-date-format
util/iso8601-usecs-date-format
util/rfc822-date-format))))

;; ----------------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/com/grzm/awyeah/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
(def iso8601-msecs-date-format
(date-format "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"))

(def iso8601-usecs-date-format
(date-format "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'"))

(def rfc822-date-format
(date-format "EEE, dd MMM yyyy HH:mm:ss z"))

Expand Down

0 comments on commit 2ac9da4

Please sign in to comment.