File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
packages/vtable-gantt/src/tools Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -677,6 +677,11 @@ export function computeCountToTimeScale(
677677
678678 let difference : number ;
679679 const adjusted_date = new Date ( date . getTime ( ) + diffMS ) ;
680+
681+ const startDaysInMonth = new Date ( startDate . getFullYear ( ) , startDate . getMonth ( ) + 1 , 0 ) . getDate ( ) ;
682+ const adjustedDaysInMonth = new Date ( adjusted_date . getFullYear ( ) , adjusted_date . getMonth ( ) + 1 , 0 ) . getDate ( ) ;
683+ console . log ( startDaysInMonth , 'startDaysInMonth' ) ;
684+
680685 switch ( timeScale ) {
681686 case 'second' :
682687 difference = ( adjusted_date . getTime ( ) - startDate . getTime ( ) ) / msInSecond ;
@@ -697,9 +702,10 @@ export function computeCountToTimeScale(
697702 difference =
698703 ( adjusted_date . getFullYear ( ) - startDate . getFullYear ( ) ) * 12 +
699704 ( adjusted_date . getMonth ( ) - startDate . getMonth ( ) ) ;
700- difference +=
701- ( adjusted_date . getDate ( ) - startDate . getDate ( ) ) /
702- new Date ( adjusted_date . getFullYear ( ) , adjusted_date . getMonth ( ) + 1 , 0 ) . getDate ( ) ;
705+
706+ // Calculate fractional difference by normalizing day progress within each specific month
707+ // This handles variable month lengths (28/29/30/31 days) correctly
708+ difference += adjusted_date . getDate ( ) / adjustedDaysInMonth - startDate . getDate ( ) / startDaysInMonth ;
703709 break ;
704710 case 'quarter' :
705711 difference =
You can’t perform that action at this time.
0 commit comments