Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d16a1f22
Unverified
Commit
d16a1f22
authored
Sep 04, 2020
by
Kenny
Committed by
GitHub
Sep 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Time format: 0 seconds is a number (#27376)
parent
444f2d58
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
packages/grafana-data/src/valueFormats/dateTimeFormatters.test.ts
+9
-0
packages/grafana-data/src/valueFormats/dateTimeFormatters.ts
+5
-0
No files found.
packages/grafana-data/src/valueFormats/dateTimeFormatters.test.ts
View file @
d16a1f22
...
@@ -12,6 +12,7 @@ import {
...
@@ -12,6 +12,7 @@ import {
toDurationInHoursMinutesSeconds
,
toDurationInHoursMinutesSeconds
,
toDurationInDaysHoursMinutesSeconds
,
toDurationInDaysHoursMinutesSeconds
,
toNanoSeconds
,
toNanoSeconds
,
toSeconds
,
}
from
'./dateTimeFormatters'
;
}
from
'./dateTimeFormatters'
;
import
{
formattedValueToString
}
from
'./valueFormats'
;
import
{
formattedValueToString
}
from
'./valueFormats'
;
import
{
toUtc
,
dateTime
}
from
'../datetime/moment_wrapper'
;
import
{
toUtc
,
dateTime
}
from
'../datetime/moment_wrapper'
;
...
@@ -331,3 +332,11 @@ describe('to nanoseconds', () => {
...
@@ -331,3 +332,11 @@ describe('to nanoseconds', () => {
expect
(
tenDays
.
suffix
).
toBe
(
' day'
);
expect
(
tenDays
.
suffix
).
toBe
(
' day'
);
});
});
});
});
describe
(
'seconds'
,
()
=>
{
it
(
'should show 0 as 0'
,
()
=>
{
const
zeroSeconds
=
toSeconds
(
0
);
expect
(
zeroSeconds
.
text
).
toBe
(
'0'
);
expect
(
zeroSeconds
.
suffix
).
toBe
(
' s'
);
});
});
packages/grafana-data/src/valueFormats/dateTimeFormatters.ts
View file @
d16a1f22
...
@@ -103,6 +103,11 @@ export function toSeconds(size: number, decimals?: DecimalCount, scaledDecimals?
...
@@ -103,6 +103,11 @@ export function toSeconds(size: number, decimals?: DecimalCount, scaledDecimals?
return
{
text
:
''
};
return
{
text
:
''
};
}
}
// If 0, use s unit instead of ns
if
(
size
===
0
)
{
return
{
text
:
'0'
,
suffix
:
' s'
};
}
// Less than 1 µs, divide in ns
// Less than 1 µs, divide in ns
if
(
Math
.
abs
(
size
)
<
0.000001
)
{
if
(
Math
.
abs
(
size
)
<
0.000001
)
{
return
toFixedScaled
(
size
*
1
e9
,
decimals
,
trySubstract
(
scaledDecimals
,
decimals
),
-
9
,
' ns'
);
return
toFixedScaled
(
size
*
1
e9
,
decimals
,
trySubstract
(
scaledDecimals
,
decimals
),
-
9
,
' ns'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment