Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5d4b1c89
Commit
5d4b1c89
authored
Jun 06, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant Date ctor utility function
This helper can be replaced with the plain `Date` constructor.
parent
7945d196
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
29 deletions
+2
-29
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+0
-15
ee/app/assets/javascripts/analytics/merge_request_analytics/utils.js
...ts/javascripts/analytics/merge_request_analytics/utils.js
+2
-3
spec/frontend/lib/utils/datetime_utility_spec.js
spec/frontend/lib/utils/datetime_utility_spec.js
+0
-11
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
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.
...
...
ee/app/assets/javascripts/analytics/merge_request_analytics/utils.js
View file @
5d4b1c89
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
,
...
...
spec/frontend/lib/utils/datetime_utility_spec.js
View file @
5d4b1c89
...
...
@@ -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
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment