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
e5dd6077
Commit
e5dd6077
authored
6 years ago
by
Simon Belak
Browse files
Options
Downloads
Patches
Plain Diff
Properly handle timezone
parent
6b2c2b2d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/automagic_dashboards/core.clj
+13
-8
13 additions, 8 deletions
src/metabase/automagic_dashboards/core.clj
src/metabase/util/date.clj
+2
-1
2 additions, 1 deletion
src/metabase/util/date.clj
with
15 additions
and
9 deletions
src/metabase/automagic_dashboards/core.clj
+
13
−
8
View file @
e5dd6077
...
...
@@ -913,28 +913,33 @@
(
defn-
humanize-datetime
[
dt
unit
]
(
let
[
dt
(
t.format/parse
dt
)
(
let
[
dt
(
date/str->date-time
dt
)
tz
(
->
date/jvm-timezone
deref
.getID
)
unparse-with-formatter
(
fn
[
formatter
dt
]
(
t.format/unparse
(
t.format/formatter
formatter
)
dt
))]
(
t.format/unparse
(
t.format/with-zone
(
t.format/formatter
formatter
)
(
t/time-zone-for-id
tz
))
dt
))]
(
case
unit
:minute
(
tru
"at {0}"
(
unparse-with-formatter
"h:mm a, MMMM d, YYYY"
dt
))
:hour
(
tru
"at {0}"
(
unparse-with-formatter
"h a, MMMM d, YYYY"
dt
))
:day
(
tru
"on {0}"
(
unparse-with-formatter
"MMMM d, YYYY"
dt
))
:week
(
tru
"in {0} week - {1}"
(
->>
dt
(
date/date-extract
:week-of-year
)
pluralize
)
(
->>
dt
(
date/date-extract
:year
)
str
))
(
->>
dt
(
date/date-extract
:week-of-year
tz
)
pluralize
)
(
->>
dt
(
date/date-extract
:year
tz
)
str
))
:month
(
tru
"in {0}"
(
unparse-with-formatter
"MMMM, YYYY"
dt
))
:quarter
(
tru
"in Q{0} - {1}"
(
date/date-extract
:quarter-of-year
dt
)
(
->>
dt
(
date/date-extract
:year
)
str
))
(
date/date-extract
:quarter-of-year
tz
dt
)
(
->>
dt
(
date/date-extract
:year
tz
)
str
))
:year
(
unparse-with-formatter
"YYYY"
dt
)
:day-of-week
(
tru
"on a {0}"
(
unparse-with-formatter
"EEEE"
dt
))
:hour-of-day
(
tru
"at {0}"
(
unparse-with-formatter
"h a"
dt
))
:month-of-year
(
unparse-with-formatter
"MMMM"
dt
)
:quarter-of-year
(
tru
"Q{0}"
(
date/date-extract
:quarter-of-year
dt
))
:quarter-of-year
(
tru
"Q{0}"
(
date/date-extract
:quarter-of-year
tz
dt
))
(
:minute-of-hour
:day-of-month
:week-of-year
)
(
date/date-extract
unit
dt
))))
:week-of-year
)
(
date/date-extract
unit
tz
dt
))))
(
defn-
field-reference->field
[
root
field-reference
]
...
...
This diff is collapsed.
Click to expand it.
src/metabase/util/date.clj
+
2
−
1
View file @
e5dd6077
...
...
@@ -40,7 +40,8 @@
"UTC TimeZone"
(
coerce-to-timezone
"UTC"
))
(
def
^
:private
jvm-timezone
(
def
jvm-timezone
"Machine time zone"
(
delay
(
coerce-to-timezone
(
System/getProperty
"user.timezone"
))))
(
defn-
warn-on-timezone-conflict
...
...
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