mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: revert to isoWeek when resolving weekly indices (#31709)
* Elasticsearch: revert to isoWeek when resolving weekly indices * Add type assertion explainer
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { TimeZone } from '../types/time';
|
||||
/* eslint-disable id-blacklist, no-restricted-imports, @typescript-eslint/ban-types */
|
||||
import moment, { Moment, MomentInput, DurationInputArg1 } from 'moment';
|
||||
import moment, { Moment, MomentInput, DurationInputArg1, DurationInputArg2 } from 'moment';
|
||||
export interface DateTimeBuiltinFormat {
|
||||
__momentBuiltinFormatBrand: any;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ export type DurationUnit =
|
||||
| 'M'
|
||||
| 'week'
|
||||
| 'weeks'
|
||||
| 'isoWeek'
|
||||
| 'w'
|
||||
| 'day'
|
||||
| 'days'
|
||||
@@ -96,7 +97,8 @@ export const toUtc = (input?: DateTimeInput, formatInput?: FormatInput): DateTim
|
||||
};
|
||||
|
||||
export const toDuration = (input?: DurationInput, unit?: DurationUnit): DateTimeDuration => {
|
||||
return moment.duration(input as DurationInputArg1, unit) as DateTimeDuration;
|
||||
// moment built-in types are a bit flaky, for example `isoWeek` is not in the type definition but it's present in the js source.
|
||||
return moment.duration(input as DurationInputArg1, unit as DurationInputArg2) as DateTimeDuration;
|
||||
};
|
||||
|
||||
export const dateTime = (input?: DateTimeInput, formatInput?: FormatInput): DateTime => {
|
||||
|
||||
Reference in New Issue
Block a user