Skip to content

Commit

Permalink
make timezone happen
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Feb 3, 2020
1 parent ebb2989 commit 337eaa7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import _ from 'lodash';
import React from 'react';
import { Subscription } from 'rxjs';
import moment from 'moment';
import moment from 'moment-timezone';
import dateMath from '@elastic/datemath';
import { i18n } from '@kbn/i18n';
import '../components/field_chooser/field_chooser';
Expand Down Expand Up @@ -353,6 +353,10 @@ function discoverController(
objectType: 'search',
sharingData: {
...sharingData,
timezone:
core.uiSettings.get('dateFormat:tz') === 'Browser'
? moment.tz.guess()
: core.uiSettings.get('dateFormat:tz'),
title: savedSearch.title,
},
isDirty: $appStatus.dirty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const executeJobFactory: ExecuteJobFactory<ESQueueWorkerExecuteFn<
const jobLogger = logger.clone([jobId]);

const {
timezone,
searchRequest,
fields,
indexPatternSavedObject,
Expand Down Expand Up @@ -99,28 +100,21 @@ export const executeJobFactory: ExecuteJobFactory<ESQueueWorkerExecuteFn<
return fieldFormatMapFactory(indexPatternSavedObject, fieldFormats);
})(),
(async () => {
const [separator, quoteValues, timezone] = await Promise.all([
const [separator, quoteValues] = await Promise.all([
uiConfig.get('csv:separator'),
uiConfig.get('csv:quoteValues'),
uiConfig.get('dateFormat:tz'),
]);

if (timezone === 'Browser') {
jobLogger.warn(
`Kibana Advanced Setting "dateFormat:tz" is set to "Browser". Dates will be formatted as UTC to avoid ambiguity.`
);
}

return {
separator,
quoteValues,
timezone,
};
})(),
]);

const generateCsv = createGenerateCsv(jobLogger);
const { content, maxSizeReached, size, csvContainsFormulas } = await generateCsv({
timezone,
searchRequest,
fields,
metaFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface CsvResultFromSearch {
}

export interface GenerateCsvParams {
timezone?: string;
searchRequest: SearchRequest;
callEndpoint: EndpointCaller;
fields: string[];
Expand All @@ -104,7 +105,6 @@ export interface GenerateCsvParams {
settings: {
separator: string;
quoteValues: boolean;
timezone: string | null;
maxSizeBytes: number;
scroll: { duration: string; size: number };
checkForFormulas?: boolean;
Expand Down

0 comments on commit 337eaa7

Please sign in to comment.