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
1eac4bbb
Commit
1eac4bbb
authored
Feb 24, 2021
by
Hariom Verma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TimeTrackingFormatter supports negative time
parent
a237a266
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
lib/gitlab/time_tracking_formatter.rb
lib/gitlab/time_tracking_formatter.rb
+9
-1
spec/lib/gitlab/time_tracking_formatter_spec.rb
spec/lib/gitlab/time_tracking_formatter_spec.rb
+6
-0
No files found.
lib/gitlab/time_tracking_formatter.rb
View file @
1eac4bbb
...
...
@@ -24,6 +24,12 @@ module Gitlab
end
def
output
(
seconds
)
seconds
.
to_i
<
0
?
negative_output
(
seconds
)
:
positive_output
(
seconds
)
end
private
def
positive_output
(
seconds
)
ChronicDuration
.
output
(
seconds
,
CUSTOM_DAY_AND_MONTH_LENGTH
.
merge
(
...
...
@@ -34,7 +40,9 @@ module Gitlab
nil
end
private
def
negative_output
(
seconds
)
"-"
+
positive_output
(
seconds
.
abs
)
end
def
limit_to_hours_setting
Gitlab
::
CurrentSettings
.
time_tracking_limit_to_hours
...
...
spec/lib/gitlab/time_tracking_formatter_spec.rb
View file @
1eac4bbb
...
...
@@ -47,5 +47,11 @@ RSpec.describe Gitlab::TimeTrackingFormatter do
it
{
expect
(
subject
).
to
eq
(
'1w 1d 1h 40m'
)
}
end
context
'handles negative time input'
do
let
(
:num_seconds
)
{
-
178_800
}
it
{
expect
(
subject
).
to
eq
(
'-1w 1d 1h 40m'
)
}
end
end
end
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