diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-01-18 15:49:22 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-01-18 15:49:22 +0000 |
commit | f208897ccbdb539eb16a72d32cce68881eaffca7 (patch) | |
tree | 1b731e73ac9bc08757c29f1fc157617221eb612c /lib | |
parent | 5e9196b3bcc31ce7fd698ed49af5d39eae1da630 (diff) | |
parent | 63b36241945a7f9bb280f360b3b269de8c5be8f6 (diff) | |
download | gitlab-ce-f208897ccbdb539eb16a72d32cce68881eaffca7.tar.gz |
Merge branch 'backport-time-tracking-ce' into 'master'
Backport timetracking to CE
See merge request !8195
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/import_export/import_export.yml | 2 | ||||
-rw-r--r-- | lib/gitlab/time_tracking_formatter.rb | 30 |
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index e6ecd118609..08ad3274b38 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -6,6 +6,7 @@ project_tree: - :events - issues: - :events + - :timelogs - notes: - :author - :events @@ -27,6 +28,7 @@ project_tree: - :events - :merge_request_diff - :events + - :timelogs - label_links: - label: :priorities diff --git a/lib/gitlab/time_tracking_formatter.rb b/lib/gitlab/time_tracking_formatter.rb new file mode 100644 index 00000000000..d09063c6c8f --- /dev/null +++ b/lib/gitlab/time_tracking_formatter.rb @@ -0,0 +1,30 @@ +module Gitlab + module TimeTrackingFormatter + extend self + + def parse(string) + with_custom_config do + ChronicDuration.parse(string, default_unit: 'hours') rescue nil + end + end + + def output(seconds) + 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 |