Defect #11290

ParseDate missing in Ruby 1.9x

Added by Jan Losinski over 5 years ago. Updated almost 5 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Ruby support
Target version:2.1.1
Resolution:Fixed Affected version:

Description

I'm running Redmine on a Ruby 1.9x interpreter. This version has no ParseDate that is used in http://www.redmine.org/projects/redmine/repository/changes/trunk/lib/SVG/Graph/TimeSeries.rb

Because you use it 2 times with the pattern

arr = ParseDate.parsedate( data[:data][i] )
t = Time.local( *arr[0,6].compact )

you can simply replace it with
t = DateTime.parse( data[:data][i] ).to_time


Related issues

Related to Redmine - Defect #12711: incorrect fix of lib/SVG/Graph/TimeSeries.rb Closed

Associated revisions

Revision 10439
Added by Jean-Philippe Lang about 5 years ago

ParseDate missing in Ruby 1.9x (#11290).

Revision 11091
Added by Toshi MARUYAMA almost 5 years ago

fix incorrect min_x_value of lib/SVG/Graph/TimeSeries.rb by r10439 (#12711, #11290)

Revision 11093
Added by Toshi MARUYAMA almost 5 years ago

Merged r11091 from trunk (#12711, #11290)

fix incorrect min_x_value of lib/SVG/Graph/TimeSeries.rb by r10439.

History

#1 Updated by Gabriel Mazetto about 5 years ago

This issue affects RedmineGraphsPlugin (which can be found at: https://github.com/hdgarrood/redmine-graphs-plugin/network

Here is a patch for 2.1.0:

diff --git a/lib/SVG/Graph/TimeSeries.rb b/lib/SVG/Graph/TimeSeries.rb
index ee47359..bfa7c96 100644
--- a/lib/SVG/Graph/TimeSeries.rb
+++ b/lib/SVG/Graph/TimeSeries.rb
@@ -1,5 +1,4 @@
 require 'SVG/Graph/Plot'
-require 'parsedate'

 module SVG
   module Graph
@@ -157,8 +156,7 @@ module SVG
         y = []
         data[:data].each_index {|i|
           if i%2 == 0
-            arr = ParseDate.parsedate( data[:data][i] )
-            t = Time.local( *arr[0,6].compact )
+            t = DateTime.parse( data[:data][i] ).to_time
             x << t.to_i
           else
             y << data[:data][i]
@@ -173,8 +171,7 @@ module SVG
       protected

       def min_x_value=(value)
-        arr = ParseDate.parsedate( value )
-        @min_x_value = Time.local( *arr[0,6].compact ).to_i
+        @min_x_value = DateTime.parse( data[:data][i] ).to_time
       end

#2 Updated by Jean-Philippe Lang about 5 years ago

  • Category set to Ruby support
  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.1.1
  • Resolution set to Fixed

Patch committed in r10439.

#3 Updated by Jean-Philippe Lang about 5 years ago

  • Status changed from Resolved to Closed

Merged in 2.1-stable.

#4 Updated by Hein Gustavsen almost 5 years ago

This patch is incorrect. Value is not used in the min_x_value method. It should look like this:

def min_x_value=(value)
  @min_x_value = DateTime.parse( value ).to_time
end

#5 Updated by Toshi MARUYAMA almost 5 years ago

Hein Gustavsen wrote:

This patch is incorrect. Value is not used in the min_x_value method. It should look like this:
[...]

I have created new issue #12711, thanks.

Also available in: Atom PDF