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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
4a95302d
Commit
4a95302d
authored
Dec 21, 2017
by
Winnie Hellmann
Committed by
Filipa Lacerda
Dec 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore missing language code in datetime_utility.js
parent
058dd30a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+13
-5
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
4a95302d
...
@@ -2,7 +2,7 @@ import timeago from 'timeago.js';
...
@@ -2,7 +2,7 @@ import timeago from 'timeago.js';
import
dateFormat
from
'
vendor/date.format
'
;
import
dateFormat
from
'
vendor/date.format
'
;
import
{
pluralize
}
from
'
./text_utility
'
;
import
{
pluralize
}
from
'
./text_utility
'
;
import
{
import
{
lang
,
lang
uageCode
,
s__
,
s__
,
}
from
'
../../locale
'
;
}
from
'
../../locale
'
;
...
@@ -24,7 +24,15 @@ export const getDayName = date => ['Sunday', 'Monday', 'Tuesday', 'Wednesday', '
...
@@ -24,7 +24,15 @@ export const getDayName = date => ['Sunday', 'Monday', 'Tuesday', 'Wednesday', '
*/
*/
export
const
formatDate
=
datetime
=>
dateFormat
(
datetime
,
'
mmm d, yyyy h:MMtt Z
'
);
export
const
formatDate
=
datetime
=>
dateFormat
(
datetime
,
'
mmm d, yyyy h:MMtt Z
'
);
/**
* Timeago uses underscores instead of dashes to separate language from country code.
*
* see https://github.com/hustcc/timeago.js/tree/v3.0.0/locales
*/
const
timeagoLanguageCode
=
languageCode
().
replace
(
/-/g
,
'
_
'
);
let
timeagoInstance
;
let
timeagoInstance
;
/**
/**
* Sets a timeago Instance
* Sets a timeago Instance
*/
*/
...
@@ -67,8 +75,8 @@ export function getTimeago() {
...
@@ -67,8 +75,8 @@ export function getTimeago() {
][
index
];
][
index
];
};
};
timeago
.
register
(
lang
,
locale
);
timeago
.
register
(
timeagoLanguageCode
,
locale
);
timeago
.
register
(
`
${
lang
}
-remaining`
,
localeRemaining
);
timeago
.
register
(
`
${
timeagoLanguageCode
}
-remaining`
,
localeRemaining
);
timeagoInstance
=
timeago
();
timeagoInstance
=
timeago
();
}
}
...
@@ -83,7 +91,7 @@ export const renderTimeago = ($els) => {
...
@@ -83,7 +91,7 @@ export const renderTimeago = ($els) => {
const
timeagoEls
=
$els
||
document
.
querySelectorAll
(
'
.js-timeago-render
'
);
const
timeagoEls
=
$els
||
document
.
querySelectorAll
(
'
.js-timeago-render
'
);
// timeago.js sets timeouts internally for each timeago value to be updated in real time
// timeago.js sets timeouts internally for each timeago value to be updated in real time
getTimeago
().
render
(
timeagoEls
,
lang
);
getTimeago
().
render
(
timeagoEls
,
timeagoLanguageCode
);
};
};
/**
/**
...
@@ -118,7 +126,7 @@ export const timeFor = (time, expiredLabel) => {
...
@@ -118,7 +126,7 @@ export const timeFor = (time, expiredLabel) => {
if
(
new
Date
(
time
)
<
new
Date
())
{
if
(
new
Date
(
time
)
<
new
Date
())
{
return
expiredLabel
||
s__
(
'
Timeago|Past due
'
);
return
expiredLabel
||
s__
(
'
Timeago|Past due
'
);
}
}
return
getTimeago
().
format
(
time
,
`
${
lang
}
-remaining`
).
trim
();
return
getTimeago
().
format
(
time
,
`
${
timeagoLanguageCode
}
-remaining`
).
trim
();
};
};
export
const
getDayDifference
=
(
a
,
b
)
=>
{
export
const
getDayDifference
=
(
a
,
b
)
=>
{
...
...
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