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
b6577d15
Commit
b6577d15
authored
Feb 25, 2020
by
Sean Arnold
Committed by
Phil Hughes
Feb 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format dates before creating timestamps
parent
e50a6361
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+1
-0
changelogs/unreleased/sarnold-format-timestamps-locally.yml
changelogs/unreleased/sarnold-format-timestamps-locally.yml
+5
-0
spec/frontend/lib/utils/datetime_utility_spec.js
spec/frontend/lib/utils/datetime_utility_spec.js
+22
-0
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
b6577d15
...
...
@@ -175,6 +175,7 @@ export const localTimeAgo = ($timeagoEls, setTimeago = true) => {
function
addTimeAgoTooltip
()
{
$timeagoEls
.
each
((
i
,
el
)
=>
{
// Recreate with custom template
el
.
setAttribute
(
'
title
'
,
formatDate
(
el
.
dateTime
));
$
(
el
).
tooltip
({
template
:
'
<div class="tooltip local-timeago" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>
'
,
...
...
changelogs/unreleased/sarnold-format-timestamps-locally.yml
0 → 100644
View file @
b6577d15
---
title
:
Fix timezones for popovers.
merge_request
:
24942
author
:
type
:
fixed
spec/frontend/lib/utils/datetime_utility_spec.js
View file @
b6577d15
import
{
__
,
s__
}
from
'
~/locale
'
;
import
$
from
'
jquery
'
;
import
'
~/commons/bootstrap
'
;
import
*
as
datetimeUtility
from
'
~/lib/utils/datetime_utility
'
;
describe
(
'
Date time utils
'
,
()
=>
{
...
...
@@ -563,3 +565,23 @@ describe('approximateDuration', () => {
expect
(
datetimeUtility
.
approximateDuration
(
seconds
)).
toBe
(
approximation
);
});
});
describe
(
'
localTimeAgo
'
,
()
=>
{
beforeEach
(()
=>
{
document
.
body
.
innerHTML
=
`<time title="some time" datetime="2020-02-18T22:22:32Z">1 hour ago</time>`
;
});
it
.
each
`
timeagoArg | title | dataOriginalTitle
${
false
}
|
${
'
some time
'
}
|
${
null
}
${
true
}
|
${
''
}
|
${
'
Feb 18, 2020 10:22pm GMT+0000
'
}
`
(
'
converts $seconds seconds to $approximation
'
,
({
timeagoArg
,
title
,
dataOriginalTitle
})
=>
{
const
element
=
document
.
querySelector
(
'
time
'
);
datetimeUtility
.
localTimeAgo
(
$
(
element
),
timeagoArg
);
jest
.
runAllTimers
();
expect
(
element
.
getAttribute
(
'
data-original-title
'
)).
toBe
(
dataOriginalTitle
);
expect
(
element
.
getAttribute
(
'
title
'
)).
toBe
(
title
);
});
});
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