edyonil / jsgantt

Automatically exported from code.google.com/p/jsgantt
0 stars 0 forks source link

Error in header row when using date format e.g. yyyy-mm-dd #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the expected output?
Header row should show 3-2 - 2008-3-2 in the header row for a week (7 
days) between 03/02/2008 - 03/08/2008. Instead the display 
shows "undefined - 2008-3-2".

Are there any specific API changes you would like to see?

Please provide any additional information below.
The issue is caused in line 631 of jsgannt.js version 1.2 where the 
substring(0,5) is take for cutting the first date of the range to 
day/month. It is necessary to cut either from beginning of the date string 
or from the end, depending whether the year is at the beginning or at the 
end of the string.

My solution that works for me: I copied the function JSGantt.formatDateStr 
and created a version named JSGantt.formatDayMonthDateStr returning only 
the Day Month combination of the date string omitting the year.
In line 631 I replaced the function call and removed the substring 
function part.

Code:
new Line 631:
JSGantt.formatDayMonthDateStr(vTmpDate,vDateDisplayFormat) + ' - ';

new function:
JSGantt.formatDayMonthDateStr = function(pDate,pFormatStr) {
       vYear4Str = pDate.getFullYear() + '';
       vYear2Str = vYear4Str.substring(2,4);
       vMonthStr = (pDate.getMonth()+1) + '';
       vDayStr   = pDate.getDate() + '';

      var vDateStr = "";    

      switch(pFormatStr) {
            case 'mm/dd/yyyy':
               return( vMonthStr + '/' + vDayStr );
            case 'dd/mm/yyyy':
               return( vDayStr + '/' + vMonthStr );
            case 'dd.mm.yyyy':
               return( vDayStr + '.' + vMonthStr );
            case 'yyyy-mm-dd':
               return( vMonthStr + '-' + vDayStr );
            case 'mm/dd/yy':
               return( vMonthStr + '/' + vDayStr );
            case 'dd/mm/yy':
               return( vDayStr + '/' + vMonthStr );
            case 'yy-mm-dd':
               return( vMonthStr + '-' + vDayStr );
            case 'mm/dd':
               return( vMonthStr + '/' + vDayStr );
            case 'dd/mm':
               return( vDayStr + '/' + vMonthStr );
      }      

}

Best regards,
Karsten

Original issue reported on code.google.com by poesc...@gmail.com on 25 Jun 2009 at 11:57

GoogleCodeExporter commented 9 years ago
fixed in jsgantt 1.2.28 , please email me your full name so I can give you 
credit on 
the source. thanks a lot for your solution.

Original comment by shlomyga...@gmail.com on 9 Jul 2009 at 8:32