[#135] Switch default timestamp timezone to UTC, add some shorthands

This commit is contained in:
Peter Taoussanis 2015-11-06 11:45:20 +07:00
parent 08f92dc205
commit 12efc4beb3
1 changed files with 23 additions and 6 deletions

View File

@ -25,11 +25,10 @@
#+clj
(def default-timestamp-opts
"Controls (:timestamp_ data)."
{:pattern "yy-MMM-dd HH:mm:ss"
:locale (java.util.Locale. "en")
;; :timezone (java.util.TimeZone/getTimeZone "UTC")
:timezone (java.util.TimeZone/getDefault)})
"Controls (:timestamp_ data)"
{:pattern "yy-MMM-dd HH:mm:ss" #_:iso8601
:locale :jvm-default #_(java.util.Locale. "en")
:timezone :utc #_(java.util.TimeZone/getTimeZone "Europe/Amsterdam")})
(declare stacktrace)
(defn default-output-fn
@ -378,7 +377,25 @@
(let [timestamp-opts (inherit-into :timestamp-opts
appender config
default-timestamp-opts)
{:keys [pattern locale timezone]} timestamp-opts]
{:keys [pattern locale timezone]} timestamp-opts
pattern
(case pattern
:iso8601 "yyyy-MM-dd HH:mm:ss.SSSZ"
:rss2 "EEE, dd MMM yyyy HH:mm:ss z"
pattern)
locale
(case locale
:jvm-default (java.util.Locale/getDefault)
locale)
timezone
(case timezone
:jvm-default (java.util.TimeZone/getDefault)
:utc (java.util.TimeZone/getTimeZone "UTC")
timezone)]
(.format (enc/simple-date-format pattern
{:locale locale :timezone timezone})
(:instant data))))