Commit 18c13707 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'vs/remove-redundant-date-utility-function' into 'master'

Remove redundant Date ctor utility function

See merge request gitlab-org/gitlab!63355
parents 595afec9 5d4b1c89
......@@ -883,21 +883,6 @@ export const approximateDuration = (seconds = 0) => {
return n__('1 day', '%d days', seconds < ONE_DAY_LIMIT ? 1 : days);
};
/**
* A utility function which helps creating a date object
* for a specific date. Accepts the year, month and day
* returning a date object for the given params.
*
* @param {Int} year the full year as a number i.e. 2020
* @param {Int} month the month index i.e. January => 0
* @param {Int} day the day as a number i.e. 23
*
* @return {Date} the date object from the params
*/
export const dateFromParams = (year, month, day) => {
return new Date(year, month, day);
};
/**
* A utility function which computes the difference in seconds
* between 2 dates.
......
import dateFormat from 'dateformat';
import {
getMonthNames,
dateFromParams,
getDateInPast,
getDayDifference,
secondsToDays,
......@@ -32,8 +31,8 @@ export const computeMonthRangeData = (startDate, endDate, format = dateFormats.i
const monthIndex = dateCursor.getMonth();
const year = dateCursor.getFullYear();
const mergedAfter = dateFromParams(year, monthIndex, 1);
const mergedBefore = dateFromParams(year, monthIndex + 1, 1);
const mergedAfter = new Date(year, monthIndex, 1);
const mergedBefore = new Date(year, monthIndex + 1, 1);
monthData.unshift({
year,
......
......@@ -889,17 +889,6 @@ describe('localTimeAgo', () => {
});
});
describe('dateFromParams', () => {
it('returns the expected date object', () => {
const expectedDate = new Date('2019-07-17T00:00:00.000Z');
const date = datetimeUtility.dateFromParams(2019, 6, 17);
expect(date.getYear()).toBe(expectedDate.getYear());
expect(date.getMonth()).toBe(expectedDate.getMonth());
expect(date.getDate()).toBe(expectedDate.getDate());
});
});
describe('differenceInSeconds', () => {
const startDateTime = new Date('2019-07-17T00:00:00.000Z');
......
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