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
412c1153
Commit
412c1153
authored
5 years ago
by
Shuai Lin
Committed by
Paul Rosenzweig
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix sqlite3 year (#11662)
parent
98a4197b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/lib/time.js
+1
-1
1 addition, 1 deletion
frontend/src/metabase/lib/time.js
frontend/test/metabase/lib/time.unit.spec.js
+10
-2
10 additions, 2 deletions
frontend/test/metabase/lib/time.unit.spec.js
with
11 additions
and
3 deletions
frontend/src/metabase/lib/time.js
+
1
−
1
View file @
412c1153
...
...
@@ -47,7 +47,7 @@ export function parseTimestamp(value, unit) {
return
value
;
}
else
if
(
typeof
value
===
"
string
"
&&
/
(
Z|
[
+-
]\d\d
:
?\d\d)
$/
.
test
(
value
))
{
return
moment
.
parseZone
(
value
);
}
else
if
(
unit
in
NUMERIC_UNIT_FORMATS
)
{
}
else
if
(
unit
in
NUMERIC_UNIT_FORMATS
&&
typeof
value
==
"
number
"
)
{
return
NUMERIC_UNIT_FORMATS
[
unit
](
value
);
}
else
{
return
moment
.
utc
(
value
);
...
...
This diff is collapsed.
Click to expand it.
frontend/test/metabase/lib/time.unit.spec.js
+
10
−
2
View file @
412c1153
...
...
@@ -9,6 +9,7 @@ describe("time", () => {
const
TEST_CASES
=
[
[
"
2015-01-01T00:00:00.000Z
"
,
0
,
NY15_UTC
],
[
"
2015-01-01
"
,
0
,
NY15_UTC
],
[
"
2015-01-01T00:00:00.000+00:00
"
,
0
,
NY15_UTC
],
[
"
2015-01-01T00:00:00.000+0000
"
,
0
,
NY15_UTC
],
[
"
2015-01-01T00:00:00Z
"
,
0
,
NY15_UTC
],
...
...
@@ -27,9 +28,9 @@ describe("time", () => {
TEST_CASES
.
map
(([
str
,
expectedOffset
,
expectedMoment
])
=>
{
it
(
str
+
"
should be parsed as
moment reprsenting
"
+
"
should be parsed as moment reprsenting
"
+
expectedMoment
+
"
with the offset
"
+
"
with the offset
"
+
expectedOffset
,
()
=>
{
const
result
=
parseTimestamp
(
str
);
...
...
@@ -40,6 +41,13 @@ describe("time", () => {
},
);
});
// See https://github.com/metabase/metabase/issues/11615
it
(
"
parse sqlite date with unit=year correctly
"
,
()
=>
{
const
result
=
parseTimestamp
(
"
2015-01-01
"
,
"
year
"
);
expect
(
moment
.
isMoment
(
result
)).
toBe
(
true
);
expect
(
result
.
unix
()).
toEqual
(
NY15_UTC
.
unix
());
});
});
describe
(
"
parseTime
"
,
()
=>
{
...
...
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