Skip to content
代码片段 群组 项目
未验证 提交 8b6da4db 编辑于 作者: Alex Pennells's avatar Alex Pennells 提交者: GitLab
浏览文件

Merge branch 'issue_338332_fix_date_timezone' into 'master'

Fix value stream analytics default date

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/167476



Merged-by: default avatarAlex Pennells <apennells@gitlab.com>
Approved-by: default avatarAlex Pennells <apennells@gitlab.com>
Reviewed-by: default avatarAlex Pennells <apennells@gitlab.com>
Co-authored-by: default avatarFelipe Artur <felipefac@gmail.com>
No related branches found
No related tags found
无相关合并请求
import { extractVSAFeaturesFromGON } from '~/analytics/shared/utils';
import { parseSeconds } from '~/lib/utils/datetime_utility';
import { parseSeconds, newDate } from '~/lib/utils/datetime_utility';
import { formatTimeAsSummary } from '~/lib/utils/datetime/date_format_utility';
import { joinPaths } from '~/lib/utils/url_utility';
......@@ -86,8 +86,8 @@ export const buildCycleAnalyticsInitialData = ({
name: namespaceName,
fullPath: namespaceFullPath,
},
createdAfter: new Date(createdAfter),
createdBefore: new Date(createdBefore),
createdAfter: newDate(createdAfter),
createdBefore: newDate(createdBefore),
selectedStage: stage ? JSON.parse(stage) : null,
features: extractVSAFeaturesFromGON(),
};
......
......@@ -7,7 +7,7 @@ import {
parseBoolean,
roundOffFloat,
} from '~/lib/utils/common_utils';
import { getDateInFuture } from '~/lib/utils/datetime/date_calculation_utility';
import { getDateInFuture, newDate } from '~/lib/utils/datetime/date_calculation_utility';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
import { DEFAULT_NULL_SERIES_OPTIONS, DEFAULT_SERIES_DATA_OPTIONS } from './constants';
......@@ -78,22 +78,6 @@ export const buildProjectFromDataset = (dataset) => {
return null;
};
/**
* Creates a new date object without time zone conversion.
*
* We use this method instead of `new Date(date)`.
* `new Date(date) will assume that the date string is UTC and it
* ant return different date depending on the user's time zone.
*
* @param {String} date - Date string.
* @returns {Date} - Date object.
*/
export const toLocalDate = (date) => {
const dateParts = date.split('-');
return new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);
};
/**
* Creates an array of project objects from a json string. Returns null if no projects are present.
*
......@@ -155,8 +139,8 @@ export const buildCycleAnalyticsInitialData = ({
)
: null,
groupPath: groupPath || groupFullPath,
createdBefore: createdBefore ? toLocalDate(createdBefore) : null,
createdAfter: createdAfter ? toLocalDate(createdAfter) : null,
createdBefore: createdBefore ? newDate(createdBefore) : null,
createdAfter: createdAfter ? newDate(createdAfter) : null,
selectedProjects: projects
? buildProjectsFromJSON(projects).map((proj) => ({
...convertObjectPropsToCamelCase(proj),
......
......@@ -3,7 +3,6 @@ import {
buildProjectFromDataset,
buildCycleAnalyticsInitialData,
buildNullSeries,
toLocalDate,
pairDataAndLabels,
linearRegression,
} from 'ee/analytics/shared/utils';
......@@ -86,14 +85,6 @@ describe('buildProjectFromDataset', () => {
});
});
describe('toLocalDate', () => {
it('returns a Date object', () => {
const expectedDate = new Date(2022, 1, 10); // month is zero-based
expect(toLocalDate('2022-02-10')).toEqual(expectedDate);
});
});
describe('buildCycleAnalyticsInitialData', () => {
it.each`
field | value
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册