Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10 in AVENGE/grafana from feature/changeDateForma…
Browse files Browse the repository at this point in the history
…ts to revdev

* commit '2964a003d8b6670795771850e794bb1aa270a753':
  Use and update the default grafana date formats so revert my hacks!
  • Loading branch information
Steve Sutton authored and stevepostill committed Sep 22, 2021
2 parents bb0153a + 2964a00 commit d6b0931
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
19 changes: 13 additions & 6 deletions conf/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -992,14 +992,21 @@ enable =
# For information on what formatting patterns that are supported https://momentjs.com/docs/#/displaying/

# Default system date format used in time range picker and other places where full time is displayed
full_date = YYYY-MM-DD HH:mm:ss
# full_date = YYYY-MM-DD HH:mm:ss
full_date = ddd DD MMM YYYY h:mm a

# Used by graph and other places where we only show small intervals
interval_second = HH:mm:ss
interval_minute = HH:mm
interval_hour = MM/DD HH:mm
interval_day = MM/DD
interval_month = YYYY-MM
# interval_second = HH:mm:ss
interval_second = H:mm:ss a
# interval_minute = HH:mm
interval_minute = h:mm a
# interval_hour = MM/DD HH:mm
interval_hour = D MMM h:mm a
# interval_day = MM/DD
interval_day = ddd D MMM
# interval_month = YYYY-MM
interval_month = MMM YYYY
# interval_year = YYYY
interval_year = YYYY

# Experimental feature
Expand Down
5 changes: 2 additions & 3 deletions packages/grafana-data/src/datetime/rangeutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,16 @@ export function describeTextRange(expr: any) {
* ```
* @category TimeUtils
* @param range - a time range (usually specified by the TimePicker)
* @param format - time format
* @alpha
*/
export function describeTimeRange(range: RawTimeRange, timeZone?: TimeZone, format?: string): string {
export function describeTimeRange(range: RawTimeRange, timeZone?: TimeZone): string {
const option = rangeIndex[range.from.toString() + ' to ' + range.to.toString()];

if (option) {
return option.display;
}

const options = { timeZone, format };
const options = { timeZone };

if (isDateTime(range.from) && isDateTime(range.to)) {
return dateTimeFormat(range.from, options) + ' to ' + dateTimeFormat(range.to, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,12 @@ const ZoomOutTooltip = () => (
const TimePickerTooltip = ({ timeRange, timeZone }: { timeRange: TimeRange; timeZone?: TimeZone }) => {
const theme = useTheme();
const styles = getLabelStyles(theme);
// TODO make configurable... .
const format = 'ddd, DD-MMM-YYYY hh:mm:ss a';

return (
<>
{dateTimeFormat(timeRange.from, { timeZone, format })}
{dateTimeFormat(timeRange.from, { timeZone })}
<div className="text-center">to</div>
{dateTimeFormat(timeRange.to, { timeZone, format })}
{dateTimeFormat(timeRange.to, { timeZone })}
<div className="text-center">
<span className={styles.utc}>{timeZoneFormatUserFriendly(timeZone)}</span>
</div>
Expand Down
3 changes: 3 additions & 0 deletions public/app/features/metric/metricApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export function saveMetric(metric: Metric) {
if (!metric.category) {
metric.category = 'grafana';
}
if (!metric.source) {
metric.source = 'grafana';
}
if (!metric.values) {
metric.values = {};
}
Expand Down

0 comments on commit d6b0931

Please sign in to comment.