mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: UI improvements (#55130)
* Public dashboard modal UI modifications
This commit is contained in:
22
public/app/features/dashboard/utils/timeRange.ts
Normal file
22
public/app/features/dashboard/utils/timeRange.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { DateTime, TimeRange } from '@grafana/data';
|
||||
import { dateMath, dateTime, isDateTime } from '@grafana/data/src';
|
||||
import { TimeModel } from 'app/features/dashboard/state/TimeModel';
|
||||
|
||||
export const getTimeRange = (
|
||||
time: { from: DateTime | string; to: DateTime | string },
|
||||
timeModel?: TimeModel
|
||||
): TimeRange => {
|
||||
// make copies if they are moment (do not want to return out internal moment, because they are mutable!)
|
||||
const raw = {
|
||||
from: isDateTime(time.from) ? dateTime(time.from) : time.from,
|
||||
to: isDateTime(time.to) ? dateTime(time.to) : time.to,
|
||||
};
|
||||
|
||||
const timezone = timeModel ? timeModel.getTimezone() : undefined;
|
||||
|
||||
return {
|
||||
from: dateMath.parse(raw.from, false, timezone, timeModel?.fiscalYearStartMonth)!,
|
||||
to: dateMath.parse(raw.to, true, timezone, timeModel?.fiscalYearStartMonth)!,
|
||||
raw: raw,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user