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
7db050d9
Unverified
Commit
7db050d9
authored
Sep 17, 2020
by
Dominik Prokop
Committed by
GitHub
Sep 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include IANA timezone canonical name in TimeZoneInfo (#27591)
parent
0e344740
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletions
+38
-1
jest.config.js
+2
-0
packages/grafana-data/src/datetime/timezones.test.ts
+31
-0
packages/grafana-data/src/datetime/timezones.ts
+5
-1
No files found.
jest.config.js
View file @
7db050d9
process
.
env
.
TZ
=
'UTC'
;
module
.
exports
=
{
verbose
:
false
,
transform
:
{
...
...
packages/grafana-data/src/datetime/timezones.test.ts
0 → 100644
View file @
7db050d9
import
{
getTimeZoneInfo
}
from
'./timezones'
;
import
{
setTimeZoneResolver
}
from
'./common'
;
describe
(
'getTimeZoneInfo'
,
()
=>
{
// global timezone is set to UTC, see jest-config.js file
describe
(
'IANA canonical name of the timezone'
,
()
=>
{
it
(
'should resolve for default timezone'
,
()
=>
{
setTimeZoneResolver
(()
=>
'browser'
);
const
result
=
getTimeZoneInfo
(
''
,
Date
.
now
());
expect
(
result
?.
ianaName
).
toBe
(
'Africa/Abidjan'
);
});
it
(
'should resolve for browser timezone'
,
()
=>
{
// global timezone is set to UTC
const
result
=
getTimeZoneInfo
(
'browser'
,
Date
.
now
());
expect
(
result
?.
ianaName
).
toBe
(
'Africa/Abidjan'
);
});
it
(
'should resolve for utc timezone'
,
()
=>
{
// global timezone is set to UTC
const
result
=
getTimeZoneInfo
(
'utc'
,
Date
.
now
());
expect
(
result
?.
ianaName
).
toBe
(
'UTC'
);
});
it
(
'should resolve for given timezone'
,
()
=>
{
// global timezone is set to UTC
const
result
=
getTimeZoneInfo
(
'Europe/Warsaw'
,
Date
.
now
());
expect
(
result
?.
ianaName
).
toBe
(
'Europe/Warsaw'
);
});
});
});
packages/grafana-data/src/datetime/timezones.ts
View file @
7db050d9
...
...
@@ -30,6 +30,7 @@ export interface TimeZoneInfo {
countries
:
TimeZoneCountry
[];
abbreviation
:
string
;
offsetInMins
:
number
;
ianaName
:
string
;
}
export
interface
GroupedTimeZones
{
...
...
@@ -98,6 +99,7 @@ const mapInternal = (zone: string, timestamp: number): TimeZoneInfo | undefined
case
InternalTimeZones
.
utc
:
{
return
{
name
:
'Coordinated Universal Time'
,
ianaName
:
'UTC'
,
zone
,
countries
:
[],
abbreviation
:
'UTC, GMT'
,
...
...
@@ -115,6 +117,7 @@ const mapInternal = (zone: string, timestamp: number): TimeZoneInfo | undefined
abbreviation
:
''
,
offsetInMins
:
0
,
...
info
,
ianaName
:
(
info
as
TimeZoneInfo
).
ianaName
,
name
:
'Default'
,
zone
,
};
...
...
@@ -130,6 +133,7 @@ const mapInternal = (zone: string, timestamp: number): TimeZoneInfo | undefined
offsetInMins
:
new
Date
().
getTimezoneOffset
(),
...
info
,
name
:
'Browser Time'
,
ianaName
:
(
info
as
TimeZoneInfo
).
ianaName
,
zone
,
};
}
...
...
@@ -148,13 +152,13 @@ const abbrevationWithoutOffset = (abbrevation: string): string => {
const
mapToInfo
=
(
timeZone
:
TimeZone
,
timestamp
:
number
):
TimeZoneInfo
|
undefined
=>
{
const
momentTz
=
moment
.
tz
.
zone
(
timeZone
);
if
(
!
momentTz
)
{
return
undefined
;
}
return
{
name
:
timeZone
,
ianaName
:
momentTz
.
name
,
zone
:
timeZone
,
countries
:
countriesByTimeZone
[
timeZone
]
??
[],
abbreviation
:
abbrevationWithoutOffset
(
momentTz
.
abbr
(
timestamp
)),
...
...
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