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
b686b3d5
Commit
b686b3d5
authored
Oct 24, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert methods to ES6 exports
parent
f5d71ad8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
39 deletions
+36
-39
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+36
-39
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
b686b3d5
...
@@ -74,10 +74,9 @@ let timeagoInstance;
...
@@ -74,10 +74,9 @@ let timeagoInstance;
/**
/**
* Sets a timeago Instance
* Sets a timeago Instance
*/
*/
export
function
getTimeago
()
{
export
const
getTimeago
=
()
=>
{
if
(
!
timeagoInstance
)
{
if
(
!
timeagoInstance
)
{
const
localeRemaining
=
function
getLocaleRemaining
(
number
,
index
)
{
const
localeRemaining
=
(
number
,
index
)
=>
[
return
[
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|%s seconds remaining
'
)],
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|%s seconds remaining
'
)],
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|1 minute remaining
'
)],
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|1 minute remaining
'
)],
...
@@ -93,9 +92,8 @@ export function getTimeago() {
...
@@ -93,9 +92,8 @@ export function getTimeago() {
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|1 year remaining
'
)],
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|1 year remaining
'
)],
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|%s years remaining
'
)],
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|%s years remaining
'
)],
][
index
];
][
index
];
};
const
locale
=
function
getLocale
(
number
,
index
)
{
const
locale
=
(
number
,
index
)
=>
[
return
[
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|in %s seconds
'
)],
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|in %s seconds
'
)],
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|in 1 minute
'
)],
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|in 1 minute
'
)],
...
@@ -111,7 +109,6 @@ export function getTimeago() {
...
@@ -111,7 +109,6 @@ export function getTimeago() {
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|in 1 year
'
)],
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|in 1 year
'
)],
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|in %s years
'
)],
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|in %s years
'
)],
][
index
];
][
index
];
};
timeago
.
register
(
timeagoLanguageCode
,
locale
);
timeago
.
register
(
timeagoLanguageCode
,
locale
);
timeago
.
register
(
`
${
timeagoLanguageCode
}
-remaining`
,
localeRemaining
);
timeago
.
register
(
`
${
timeagoLanguageCode
}
-remaining`
,
localeRemaining
);
...
@@ -184,7 +181,7 @@ export const getDayDifference = (a, b) => {
...
@@ -184,7 +181,7 @@ export const getDayDifference = (a, b) => {
* @param {Number} seconds
* @param {Number} seconds
* @return {String}
* @return {String}
*/
*/
export
function
timeIntervalInWords
(
intervalInSeconds
)
{
export
const
timeIntervalInWords
=
(
intervalInSeconds
)
=>
{
const
secondsInteger
=
parseInt
(
intervalInSeconds
,
10
);
const
secondsInteger
=
parseInt
(
intervalInSeconds
,
10
);
const
minutes
=
Math
.
floor
(
secondsInteger
/
60
);
const
minutes
=
Math
.
floor
(
secondsInteger
/
60
);
const
seconds
=
secondsInteger
-
minutes
*
60
;
const
seconds
=
secondsInteger
-
minutes
*
60
;
...
@@ -198,7 +195,7 @@ export function timeIntervalInWords(intervalInSeconds) {
...
@@ -198,7 +195,7 @@ export function timeIntervalInWords(intervalInSeconds) {
return
text
;
return
text
;
}
}
export
function
dateInWords
(
date
,
abbreviated
=
false
,
hideYear
=
false
)
{
export
const
dateInWords
=
(
date
,
abbreviated
=
false
,
hideYear
=
false
)
=>
{
if
(
!
date
)
return
date
;
if
(
!
date
)
return
date
;
const
month
=
date
.
getMonth
();
const
month
=
date
.
getMonth
();
...
...
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