Skip to content

Commit e6a3f98

Browse files
authored
Fix browser date format (#57714) (#58146)
* fix browser date formatter
1 parent 9ab75a3 commit e6a3f98

File tree

22 files changed

+174
-24
lines changed

22 files changed

+174
-24
lines changed

src/plugins/data/common/field_formats/constants/base_formatters.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
BoolFormat,
2424
BytesFormat,
2525
ColorFormat,
26-
DateFormat,
2726
DateNanosFormat,
2827
DurationFormat,
2928
IpFormat,
@@ -41,7 +40,6 @@ export const baseFormatters: IFieldFormatType[] = [
4140
BoolFormat,
4241
BytesFormat,
4342
ColorFormat,
44-
DateFormat,
4543
DateNanosFormat,
4644
DurationFormat,
4745
IpFormat,

src/plugins/data/common/field_formats/converters/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
export { UrlFormat } from './url';
2121
export { BytesFormat } from './bytes';
22-
export { DateFormat } from './date_server';
2322
export { DateNanosFormat } from './date_nanos';
2423
export { RelativeDateFormat } from './relative_date';
2524
export { DurationFormat } from './duration';

src/plugins/data/common/field_formats/field_formats_registry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export class FieldFormatsRegistry {
9595
return undefined;
9696
};
9797

98+
getTypeWithoutMetaParams = (formatId: FieldFormatId): IFieldFormatType | undefined => {
99+
return this.fieldFormats.get(formatId);
100+
};
101+
98102
/**
99103
* Get the default FieldFormat type (class) for
100104
* a field type, using the format:defaultTypeMap.

src/plugins/data/common/field_formats/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export {
2727
BoolFormat,
2828
BytesFormat,
2929
ColorFormat,
30-
DateFormat,
3130
DateNanosFormat,
3231
DurationFormat,
3332
IpFormat,

src/plugins/data/common/field_formats/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import { FieldFormat } from './field_format';
21+
export { FieldFormat };
2122

2223
/** @public **/
2324
export type FieldFormatsContentType = 'html' | 'text';

src/plugins/data/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ export * from './timefilter/types';
2121
export * from './query/types';
2222
export * from './kbn_field_types/types';
2323
export * from './index_patterns/types';
24+
export { TextContextTypeConvert, IFieldFormatMetaParams } from './field_formats/types';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { baseFormatters } from '../../common';
21+
import { DateFormat } from './converters/date';
22+
23+
export const baseFormattersPublic = [DateFormat, ...baseFormatters];

src/plugins/data/common/field_formats/converters/date.ts renamed to src/plugins/data/public/field_formats/converters/date.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
import { i18n } from '@kbn/i18n';
2121
import { memoize, noop } from 'lodash';
2222
import moment from 'moment';
23-
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
24-
import { FieldFormat } from '../field_format';
25-
import { TextContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
23+
import {
24+
FieldFormat,
25+
KBN_FIELD_TYPES,
26+
TextContextTypeConvert,
27+
FIELD_FORMAT_IDS,
28+
} from '../../../common';
2629

2730
export class DateFormat extends FieldFormat {
2831
static id = FIELD_FORMAT_IDS.DATE;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
export { DateFormat } from './date';

0 commit comments

Comments
 (0)