Module: Gitlab::TimeTrackingFormatter
- Extended by:
- TimeTrackingFormatter
- Included in:
- TimeTrackingFormatter
- Defined in:
- lib/gitlab/time_tracking_formatter.rb
Constant Summary collapse
- CUSTOM_DAY_AND_MONTH_LENGTH =
We may want to configure it through project settings in a future version.
{ hours_per_day: 8, days_per_month: 20 }.freeze
Instance Method Summary collapse
Instance Method Details
#output(seconds) ⇒ Object
27 28 29 |
# File 'lib/gitlab/time_tracking_formatter.rb', line 27 def output(seconds) seconds.to_i < 0 ? negative_output(seconds) : positive_output(seconds) end |
#parse(string) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/time_tracking_formatter.rb', line 10 def parse(string) negative_time = string.start_with?('-') string = string.delete_prefix('-') seconds = begin ChronicDuration.parse( string, CUSTOM_DAY_AND_MONTH_LENGTH.merge(default_unit: 'hours')) rescue StandardError nil end seconds *= -1 if seconds && negative_time seconds end |