diff --git a/packages/grafana-data/src/datetime/timezones.ts b/packages/grafana-data/src/datetime/timezones.ts index c9f01072621..d763fb3a995 100644 --- a/packages/grafana-data/src/datetime/timezones.ts +++ b/packages/grafana-data/src/datetime/timezones.ts @@ -1,5 +1,18 @@ -// List taken from https://stackoverflow.com/questions/38399465/how-to-get-list-of-all-timezones-in-javascript +import { TimeZone } from '../types'; +import { getTimeZone } from './common'; +export const timeZoneFormatUserFriendly = (timeZone: TimeZone | undefined) => { + switch (getTimeZone({ timeZone })) { + case 'browser': + return 'Local browser time'; + case 'utc': + return 'UTC'; + default: + return timeZone; + } +}; + +// List taken from https://stackoverflow.com/questions/38399465/how-to-get-list-of-all-timezones-in-javascript export const getTimeZoneGroups = () => { const europeZones = [ 'Europe/Amsterdam', diff --git a/packages/grafana-ui/src/components/TimePicker/TimeRangePicker.tsx b/packages/grafana-ui/src/components/TimePicker/TimeRangePicker.tsx index 88b15f0e915..e3fc1e64ef0 100644 --- a/packages/grafana-ui/src/components/TimePicker/TimeRangePicker.tsx +++ b/packages/grafana-ui/src/components/TimePicker/TimeRangePicker.tsx @@ -13,7 +13,7 @@ import { stylesFactory } from '../../themes/stylesFactory'; import { withTheme, useTheme } from '../../themes/ThemeContext'; // Types -import { isDateTime, rangeUtil, GrafanaTheme, dateTimeFormatWithAbbrevation } from '@grafana/data'; +import { isDateTime, rangeUtil, GrafanaTheme, dateTimeFormat, timeZoneFormatUserFriendly } from '@grafana/data'; import { TimeRange, TimeOption, TimeZone, dateMath } from '@grafana/data'; import { Themeable } from '../../types'; @@ -206,13 +206,21 @@ const ZoomOutTooltip = () => ( > ); -const TimePickerTooltip = ({ timeRange, timeZone }: { timeRange: TimeRange; timeZone?: TimeZone }) => ( - <> - {dateTimeFormatWithAbbrevation(timeRange.from, { timeZone })} -