Commit f0831056 authored by Ruben Davila's avatar Ruben Davila

Alter ChronicDuration config only for Time Tracking stuff.

parent 77eea067
ChronicDuration.raise_exceptions = true
# We may want to configure it through project settings in a future version.
ChronicDuration.hours_per_day = 8
ChronicDuration.days_per_week = 5
......@@ -3,13 +3,28 @@ module Gitlab
extend self
def parse(string)
ChronicDuration.parse(string, default_unit: 'hours')
rescue ChronicDuration::DurationParseError
nil
with_custom_config do
ChronicDuration.parse(string, default_unit: 'hours') rescue nil
end
end
def output(seconds)
ChronicDuration.output(seconds, format: :short, limit_to_hours: false, weeks: true)
with_custom_config do
ChronicDuration.output(seconds, format: :short, limit_to_hours: false, weeks: true) rescue nil
end
end
def with_custom_config
# We may want to configure it through project settings in a future version.
ChronicDuration.hours_per_day = 8
ChronicDuration.days_per_week = 5
result = yield
ChronicDuration.hours_per_day = 24
ChronicDuration.days_per_week = 7
result
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment