Project

General

Profile

Defect #5822 » Redmine_Datetime_Patch.patch

William Wedin, 2010-09-24 21:46

View differences:

lib/redmine/helpers/calendar.rb (working copy)
48 48
      # Sets calendar events
49 49
      def events=(events)
50 50
        @events = events
51
        @ending_events_by_days = @events.group_by {|event| event.due_date}
52
        @starting_events_by_days = @events.group_by {|event| event.start_date}
51
        @ending_events_by_days = @events.group_by {|event| event.due_date ? event.due_date.to_date() : nil}
52
        @starting_events_by_days = @events.group_by {|event| event.start_date ? event.start_date.to_date() : nil}
53 53
      end
54 54
      
55 55
      # Returns events for the given day
lib/redmine/helpers/gantt.rb (working copy)
292 292
          case options[:format]
293 293
          when :html
294 294
            output = ''
295
            i_left = ((project.start_date - self.date_from)*options[:zoom]).floor
295
            i_left = ((project.start_date.to_date - self.date_from)*options[:zoom]).floor
296 296

  
297
            start_date = project.start_date
297
            start_date = project.start_date.to_date
298 298
            start_date ||= self.date_from
299 299
            start_left = ((start_date - self.date_from)*options[:zoom]).floor
300 300

  
301
            i_end_date = ((project.due_date <= self.date_to) ? project.due_date : self.date_to )
302
            i_done_date = start_date + ((project.due_date - start_date+1)* project.completed_percent(:include_subprojects => true)/100).floor
301
            i_end_date = ((project.due_date.to_date <= self.date_to) ? project.due_date.to_date : self.date_to )
302
            i_done_date = start_date + ((project.due_date.to_date - start_date+1)* project.completed_percent(:include_subprojects => true)/100).floor
303 303
            i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date )
304 304
            i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date )
305 305
            
......
353 353
            output
354 354
          when :image
355 355
            options[:image].stroke('transparent')
356
            i_left = options[:subject_width] + ((project.due_date - self.date_from)*options[:zoom]).floor
356
            i_left = options[:subject_width] + ((project.due_date.to_date - self.date_from)*options[:zoom]).floor
357 357

  
358 358
            # Make sure negative i_left doesn't overflow the subject
359 359
            if i_left > options[:subject_width]
......
364 364
            end
365 365
          when :pdf
366 366
            options[:pdf].SetY(options[:top]+1.5)
367
            i_left = ((project.due_date - @date_from)*options[:zoom])
367
            i_left = ((project.due_date.to_date - @date_from)*options[:zoom])
368 368

  
369 369
            # Make sure negative i_left doesn't overflow the subject
370 370
            if i_left > 0
......
426 426
          case options[:format]
427 427
          when :html
428 428
            output = ''
429
            i_left = ((version.start_date - self.date_from)*options[:zoom]).floor
429
            i_left = ((version.start_date.to_date - self.date_from)*options[:zoom]).floor
430 430
            # TODO: or version.fixed_issues.collect(&:start_date).min
431 431
            start_date = version.fixed_issues.minimum('start_date') if version.fixed_issues.present?
432 432
            start_date ||= self.date_from
433
			start_date = start_date.to_date
433 434
            start_left = ((start_date - self.date_from)*options[:zoom]).floor
434 435

  
435
            i_end_date = ((version.due_date <= self.date_to) ? version.due_date : self.date_to )
436
            i_done_date = start_date + ((version.due_date - start_date+1)* version.completed_pourcent/100).floor
436
            i_end_date = ((version.due_date.to_date <= self.date_to) ? version.due_date.to_date : self.date_to )
437
            i_done_date = start_date + ((version.due_date.to_date - start_date+1)* version.completed_pourcent/100).floor
437 438
            i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date )
438 439
            i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date )
439 440
            
......
488 489
            output
489 490
          when :image
490 491
            options[:image].stroke('transparent')
491
            i_left = options[:subject_width] + ((version.start_date - @date_from)*options[:zoom]).floor
492
            i_left = options[:subject_width] + ((version.start_date.to_date - @date_from)*options[:zoom]).floor
492 493

  
493 494
            # Make sure negative i_left doesn't overflow the subject
494 495
            if i_left > options[:subject_width]
......
499 500
            end
500 501
          when :pdf
501 502
            options[:pdf].SetY(options[:top]+1.5)
502
            i_left = ((version.start_date - @date_from)*options[:zoom]) 
503
            i_left = ((version.start_date.to_date - @date_from)*options[:zoom]) 
503 504

  
504 505
            # Make sure negative i_left doesn't overflow the subject
505 506
            if i_left > 0
......
580 581
            output = ''
581 582
            # Handle nil start_dates, rare but can happen.
582 583
            i_start_date =  if issue.start_date && issue.start_date >= self.date_from
583
                              issue.start_date
584
                              issue.start_date.to_date
584 585
                            else
585 586
                              self.date_from
586 587
                            end
587 588

  
588
            i_end_date = ((issue.due_before && issue.due_before <= self.date_to) ? issue.due_before : self.date_to )
589
            i_done_date = i_start_date + ((issue.due_before - i_start_date+1)*issue.done_ratio/100).floor
589
			i_end_date = ((issue.due_before.to_date && issue.due_before.to_date <= self.date_to) ? issue.due_before.to_date : self.date_to )
590
            debugger
591
			i_done_date = i_start_date + ((issue.due_before.to_date - i_start_date+1)*issue.done_ratio/100).floor
590 592
            i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date )
591 593
            i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date )
592 594
            
......
635 637
                              @date_from
636 638
                            end
637 639

  
638
            i_end_date = (issue.due_before <= date_to ? issue.due_before : date_to )        
639
            i_done_date = i_start_date + ((issue.due_before - i_start_date+1)*issue.done_ratio/100).floor
640
            i_end_date = (issue.due_before.to_date <= date_to ? issue.due_before.to_date : date_to )        
641
            i_done_date = i_start_date + ((issue.due_before.to_date - i_start_date+1)*issue.done_ratio/100).floor
640 642
            i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
641 643
            i_done_date = (i_done_date >= date_to ? date_to : i_done_date )        
642 644
            i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
......
675 677
                          @date_from
676 678
                        end
677 679

  
678
            i_end_date = (issue.due_before <= @date_to ? issue.due_before : @date_to )
680
            i_end_date = (issue.due_before.to_date <= @date_to ? issue.due_before.to_date : @date_to )
679 681
            
680
            i_done_date = i_start_date + ((issue.due_before - i_start_date+1)*issue.done_ratio/100).floor
682
            i_done_date = i_start_date + ((issue.due_before.to_date - i_start_date+1)*issue.done_ratio/100).floor
681 683
            i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
682 684
            i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
683 685
            
(1-1/2)