Project

General

Profile

Actions

Defect #31637

open

CSV and PDF export don't respect Time span format

Added by Teko Teleko over 5 years ago. Updated almost 4 years ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
Time tracking
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

In Spent time section I have issues displaying the hours in standard time format, but when I export to CSV the hours are displayed in decimal format.

For example: I have a issue with 00:45h (standard), but in the CSV file I have 0.75 (decimal).

How can I export with standard time format?

I'm using the Bitnami Redmine Stack and this are my Redmine configurations:
Environment:
Redmine version 3.4.2.stable
Ruby version 2.3.4-p301 (2017-03-30) [x86_64-linux]
Rails version 4.2.8
Environment production
Database adapter Mysql2
SCM:
Subversion 1.9.7
Cvs 1.12.13
Filesystem
Redmine plugins:
redmine_checklists 3.1.15
redmine_custom_css 0.1.6


Files


Related issues

Related to Redmine - Defect #35726: Time Formatting does not apply to CSV exportsConfirmed

Actions
Actions #1

Updated by Go MAEDA over 5 years ago

  • Category set to Time tracking
Actions #3

Updated by Go MAEDA over 4 years ago

I think the exported CSV file should follow the "time span format" as well. Probably users who want to see the time in "00:45" format on the screen want to see in the same format in the CSV file.

Actions #4

Updated by Seiei Miyagi over 4 years ago

PDF export has same bug

Actions #5

Updated by Seiei Miyagi over 4 years ago

  • File 0001-Fix-csv-format-of-hours.patch added

I wrote a patch with Kusukawa and Mattani

Actions #6

Updated by Marius BÄ‚LTEANU over 4 years ago

Seiei Miyagi wrote:

I wrote a patch with Kusukawa and Mattani

Thanks for writing the patch. Can you add a new test or new assertions to existing tests?

Actions #7

Updated by Seiei Miyagi over 4 years ago

Marius BALTEANU wrote:

Seiei Miyagi wrote:

I wrote a patch with Kusukawa and Mattani

Thanks for writing the patch. Can you add a new test or new assertions to existing tests?

I added a test.

Actions #8

Updated by Seiei Miyagi over 4 years ago

  • File 0001-Fix-timespan-format-of-PDF-download.patch added

I also write a patch for PDF download timespan format.
Should I create a new ticket for that?

Actions #9

Updated by Seiei Miyagi over 4 years ago

Seiei Miyagi wrote:

I also write a patch for PDF download timespan format.
Should I create a new ticket for that?

I updated the patch, added a test for IssuesPdfHelper too.

Actions #10

Updated by Go MAEDA over 4 years ago

  • Subject changed from Problem with time format on CSV export to CSV and PDF export of Problem with time format on CSV export

Thank you for posting the patches but issues_pdf_test.rb fails.

Error:
IssuesPdfHelperTest#test_fetch_row_values_should_round_float_values:
NoMethodError: undefined method `format_hours' for #<IssuesPdfHelperTest:0x00007fcaf3326b60>
    lib/redmine/export/pdf/issues_pdf_helper.rb:389:in `block in fetch_row_values'
    lib/redmine/export/pdf/issues_pdf_helper.rb:376:in `collect'
    lib/redmine/export/pdf/issues_pdf_helper.rb:376:in `fetch_row_values'
    test/unit/lib/redmine/export/pdf/issues_pdf_test.rb:36:in `test_fetch_row_values_should_round_float_values'

bin/rails test test/unit/lib/redmine/export/pdf/issues_pdf_test.rb:28

Maybe we have to add include Redmine::I18n as follows, don't we?

diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index b49691695..8dcd52245 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -21,6 +21,8 @@ module Redmine
   module Export
     module PDF
       module IssuesPdfHelper
+        include Redmine::I18n
+
         # Returns a PDF string of a single issue
         def issue_to_pdf(issue, assoc={})
           pdf = ITCPDF.new(current_language)
Actions #11

Updated by Go MAEDA over 4 years ago

  • Subject changed from CSV and PDF export of Problem with time format on CSV export to CSV and PDF export don't respect Time span format
Actions #12

Updated by Go MAEDA over 4 years ago

  • File deleted (0001-Fix-csv-format-of-hours.patch)
Actions #13

Updated by Go MAEDA over 4 years ago

  • File deleted (0001-Fix-timespan-format-of-PDF-download.patch)
Actions #14

Updated by Go MAEDA over 4 years ago

  • Target version set to Candidate for next major release

Go MAEDA wrote:

Thank you for posting the patches but issues_pdf_test.rb fails.

[...]

Maybe we have to add include Redmine::I18n as follows, don't we?

[...]

Sorry, I applied the older patch. The latest patch has no problem. The patches work fine now.

Actions #15

Updated by Go MAEDA over 4 years ago

  • Target version changed from Candidate for next major release to 4.2.0

Setting the target version to 4.2.0.

Actions #16

Updated by Go MAEDA over 4 years ago

The patch 0001-Fix-csv-format-of-hours.patch breaks an existing test:

Failure:
IssuesControllerTest#test_index_csv_fr [/Users/maeda/redmines/redmine-trunk/test/functional/issues_controller_test.rb:1064]:
"24;1234,50;test_index_csv_fr" not found in "["#;Temps estim\xE9;Sujet", "24;1234.50;test_index_csv_fr"]" 

bin/rails test test/functional/issues_controller_test.rb:1048
Actions #17

Updated by Go MAEDA over 4 years ago

  • Target version changed from 4.2.0 to Candidate for next major release

Go MAEDA wrote:

The patch 0001-Fix-csv-format-of-hours.patch breaks an existing test:

[...]

It is because the suggested patch does not take general_csv_decimal_separator (source:branches/4.1-stable/config/locales/en.yml#L148) into account. After applying the patch, "." is always used as a decimal separator for time values ignoring general_csv_decimal_separator.

Actions #18

Updated by Go MAEDA about 4 years ago

  • Target version deleted (Candidate for next major release)
Actions #19

Updated by Go MAEDA about 4 years ago

  • Status changed from New to Confirmed
Actions #20

Updated by Mizuki ISHIKAWA about 4 years ago

Go MAEDA wrote:

Go MAEDA wrote:

The patch 0001-Fix-csv-format-of-hours.patch breaks an existing test:

[...]

It is because the suggested patch does not take general_csv_decimal_separator (source:branches/4.1-stable/config/locales/en.yml#L148) into account. After applying the patch, "." is always used as a decimal separator for time values ignoring general_csv_decimal_separator.

The following changes should fix it.

diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 6271334ae..54aec4f24 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -267,7 +267,7 @@ module QueriesHelper
     when :attachments
       value.to_a.map {|a| a.filename}.join("\n")
     when :hours, :estimated_hours, :total_estimated_hours, :spent_hours, :total_spent_hours
-      format_hours(value)
+      format_hours(value).gsub('.', l(:general_csv_decimal_separator))
     else
       format_object(value, false) do |value|
         case value.class.name

Actions #21

Updated by Go MAEDA about 4 years ago

  • Target version set to Candidate for next major release
Actions #22

Updated by Go MAEDA about 4 years ago

  • Target version changed from Candidate for next major release to 4.2.0

Setting the target version to 4.2.0.

Actions #23

Updated by Go MAEDA almost 4 years ago

  • Target version changed from 4.2.0 to Candidate for next major release

The fix #31637#note-20 changes decimal separators of the web UI as well as CSV and PDF.

However, after applying it, even though the decimal point is displayed according to the general_csv_decimal_separator on the screen, the form currently only accepts ". This can confuse users.

Actions #24

Updated by Go MAEDA almost 3 years ago

  • Related to Defect #35726: Time Formatting does not apply to CSV exports added
Actions

Also available in: Atom PDF