Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
f260b0c7
Commit
f260b0c7
authored
10 years ago
by
Cam Saül
Browse files
Options
Downloads
Plain Diff
Merge pull request #122 from metabase/use_milliseconds
Use milliseconds in date formats
parents
3889ca24
c18b5034
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/api/annotation.clj
+2
-2
2 additions, 2 deletions
src/metabase/api/annotation.clj
src/metabase/middleware/format.clj
+5
-0
5 additions, 0 deletions
src/metabase/middleware/format.clj
src/metabase/util.clj
+3
-14
3 additions, 14 deletions
src/metabase/util.clj
with
10 additions
and
16 deletions
src/metabase/api/annotation.clj
+
2
−
2
View file @
f260b0c7
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
src/metabase/middleware/format.clj
+
5
−
0
View file @
f260b0c7
...
...
@@ -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."
...
...
This diff is collapsed.
Click to expand it.
src/metabase/util.clj
+
3
−
14
View file @
f260b0c7
...
...
@@ -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`."
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment