Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

xls: display full datetime if end_time is on another day

as-op4895aaae7e53
diff --git a/modules/reporting/lib/open_project/reporting/cost_entry_xls_table.rb b/modules/reporting/lib/open_project/reporting/cost_entry_xls_table.rb
index 75fb34604ef..5f821761393 100644
--- a/modules/reporting/lib/open_project/reporting/cost_entry_xls_table.rb
+++ b/modules/reporting/lib/open_project/reporting/cost_entry_xls_table.rb
@@ -58,15 +58,20 @@ class OpenProject::Reporting::CostEntryXlsTable < OpenProject::XlsExport::XlsVie
end
def cost_main_times_columns(result)
- start_timestamp = result.start_timestamp
- end_timestamp = result.end_timestamp
- days_between_suffix = days_between_representation(start_timestamp, end_timestamp)
[
- format_time(start_timestamp, include_date: false),
- "#{format_time(end_timestamp, include_date: false)}#{days_between_suffix}"
+ format_time(result.start_timestamp, include_date: false),
+ cost_main_end_time_column(result.start_timestamp, result.end_timestamp)
]
end
+ def cost_main_end_time_column(start_timestamp, end_timestamp)
+ return "" if start_timestamp.nil? || end_timestamp.nil?
+
+ days_between = (end_timestamp.to_date - start_timestamp.to_date).to_i
+ day_prefix = days_between > 1 ? "#{end_timestamp.to_date.iso8601} " : ""
+ "#{day_prefix}#{format_time(end_timestamp, include_date: false)}"
+ end
+
def cost_main_columns(result)
main_cols = [show_field(:spent_on, result.fields[:spent_on.to_s])]
main_cols.concat cost_main_times_columns(result) if with_times_column?