Commit d4633b0e authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 2abb1b54
......@@ -555,5 +555,9 @@ export const calculateRemainingMilliseconds = endDate => {
* @param {number} daysInPast number of days that are subtracted from a given date
* @returns {String} Date string in ISO format
*/
export const getDateInPast = (date, daysInPast) =>
new Date(date.setTime(date.getTime() - daysInPast * 24 * 60 * 60 * 1000)).toISOString();
export const getDateInPast = (date, daysInPast) => {
const dateClone = newDate(date);
return new Date(
dateClone.setTime(dateClone.getTime() - daysInPast * 24 * 60 * 60 * 1000),
).toISOString();
};
......@@ -43,7 +43,7 @@
.row
.col-sm-9
= form_tag admin_runners_path, id: 'runners-search', method: :get, class: 'filter-form js-filter-form' do
.filtered-search-wrapper
.filtered-search-wrapper.d-flex
.filtered-search-box
= dropdown_tag(custom_icon('icon_history'),
options: { wrapper_class: 'filtered-search-history-dropdown-wrapper',
......
......@@ -428,11 +428,16 @@ describe('newDate', () => {
});
describe('getDateInPast', () => {
const date = new Date(1563235200000); // 2019-07-16T00:00:00.000Z;
const daysInPast = 90;
it('returns the correct date in the past', () => {
const date = new Date(1563235200000); // 2019-07-16T00:00:00.00Z
const daysInPast = 90;
const dateInPast = datetimeUtility.getDateInPast(date, daysInPast);
expect(dateInPast).toBe('2019-04-17T00:00:00.000Z');
});
it('does not modifiy the original date', () => {
datetimeUtility.getDateInPast(date, daysInPast);
expect(date).toStrictEqual(new Date(1563235200000));
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment