@@ -435,15 +435,13 @@ export class TaskDetailsComponent extends Component {
435435 cls : "date-input" ,
436436 } ) ;
437437 if ( task . metadata . dueDate ) {
438- // Use local date to avoid timezone issues
438+ // Use UTC methods to avoid timezone issues
439439 const date = new Date ( task . metadata . dueDate ) ;
440- const year = date . getFullYear ( ) ;
441- const month = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
442- const day = String ( date . getDate ( ) ) . padStart ( 2 , "0" ) ;
440+ const year = date . getUTCFullYear ( ) ;
441+ const month = String ( date . getUTCMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
442+ const day = String ( date . getUTCDate ( ) ) . padStart ( 2 , "0" ) ;
443443 dueDateInput . value = `${ year } -${ month } -${ day } ` ;
444- }
445-
446- // Start date
444+ } // Start date
447445 const startDateField = this . createFormField (
448446 this . editFormEl ,
449447 t ( "Start Date" )
@@ -453,11 +451,11 @@ export class TaskDetailsComponent extends Component {
453451 cls : "date-input" ,
454452 } ) ;
455453 if ( task . metadata . startDate ) {
456- // Use local date to avoid timezone issues
454+ // Use UTC methods to avoid timezone issues
457455 const date = new Date ( task . metadata . startDate ) ;
458- const year = date . getFullYear ( ) ;
459- const month = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
460- const day = String ( date . getDate ( ) ) . padStart ( 2 , "0" ) ;
456+ const year = date . getUTCFullYear ( ) ;
457+ const month = String ( date . getUTCMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
458+ const day = String ( date . getUTCDate ( ) ) . padStart ( 2 , "0" ) ;
461459 startDateInput . value = `${ year } -${ month } -${ day } ` ;
462460 }
463461
@@ -471,11 +469,11 @@ export class TaskDetailsComponent extends Component {
471469 cls : "date-input" ,
472470 } ) ;
473471 if ( task . metadata . scheduledDate ) {
474- // Use local date to avoid timezone issues
472+ // Use UTC methods to avoid timezone issues
475473 const date = new Date ( task . metadata . scheduledDate ) ;
476- const year = date . getFullYear ( ) ;
477- const month = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
478- const day = String ( date . getDate ( ) ) . padStart ( 2 , "0" ) ;
474+ const year = date . getUTCFullYear ( ) ;
475+ const month = String ( date . getUTCMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
476+ const day = String ( date . getUTCDate ( ) ) . padStart ( 2 , "0" ) ;
479477 scheduledDateInput . value = `${ year } -${ month } -${ day } ` ;
480478 }
481479
@@ -489,11 +487,11 @@ export class TaskDetailsComponent extends Component {
489487 cls : "date-input" ,
490488 } ) ;
491489 if ( task . metadata . cancelledDate ) {
492- // Use local date to avoid timezone issues
490+ // Use UTC methods to avoid timezone issues
493491 const date = new Date ( task . metadata . cancelledDate ) ;
494- const year = date . getFullYear ( ) ;
495- const month = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
496- const day = String ( date . getDate ( ) ) . padStart ( 2 , "0" ) ;
492+ const year = date . getUTCFullYear ( ) ;
493+ const month = String ( date . getUTCMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
494+ const day = String ( date . getUTCDate ( ) ) . padStart ( 2 , "0" ) ;
497495 cancelledDateInput . value = `${ year } -${ month } -${ day } ` ;
498496 }
499497
@@ -550,9 +548,9 @@ export class TaskDetailsComponent extends Component {
550548 // Parse dates and check if they've changed
551549 const dueDateValue = dueDateInput . value ;
552550 if ( dueDateValue ) {
553- // Create date in local timezone to avoid timezone offset issues
551+ // Create date at noon UTC to avoid timezone edge cases
554552 const [ year , month , day ] = dueDateValue . split ( "-" ) . map ( Number ) ;
555- const newDueDate = new Date ( year , month - 1 , day ) . getTime ( ) ;
553+ const newDueDate = new Date ( Date . UTC ( year , month - 1 , day , 12 , 0 , 0 ) ) . getTime ( ) ;
556554 // Only update if the date has changed or is different from the original
557555 if ( task . metadata . dueDate !== newDueDate ) {
558556 metadata . dueDate = newDueDate ;
@@ -569,11 +567,11 @@ export class TaskDetailsComponent extends Component {
569567
570568 const startDateValue = startDateInput . value ;
571569 if ( startDateValue ) {
572- // Create date in local timezone to avoid timezone offset issues
570+ // Create date at noon UTC to avoid timezone edge cases
573571 const [ year , month , day ] = startDateValue
574572 . split ( "-" )
575573 . map ( Number ) ;
576- const newStartDate = new Date ( year , month - 1 , day ) . getTime ( ) ;
574+ const newStartDate = new Date ( Date . UTC ( year , month - 1 , day , 12 , 0 , 0 ) ) . getTime ( ) ;
577575 // Only update if the date has changed or is different from the original
578576 if ( task . metadata . startDate !== newStartDate ) {
579577 metadata . startDate = newStartDate ;
@@ -590,14 +588,12 @@ export class TaskDetailsComponent extends Component {
590588
591589 const scheduledDateValue = scheduledDateInput . value ;
592590 if ( scheduledDateValue ) {
593- // Create date in local timezone to avoid timezone offset issues
591+ // Create date at noon UTC to avoid timezone edge cases
594592 const [ year , month , day ] = scheduledDateValue
595593 . split ( "-" )
596594 . map ( Number ) ;
597595 const newScheduledDate = new Date (
598- year ,
599- month - 1 ,
600- day
596+ Date . UTC ( year , month - 1 , day , 12 , 0 , 0 )
601597 ) . getTime ( ) ;
602598 // Only update if the date has changed or is different from the original
603599 if ( task . metadata . scheduledDate !== newScheduledDate ) {
@@ -615,14 +611,12 @@ export class TaskDetailsComponent extends Component {
615611
616612 const cancelledDateValue = cancelledDateInput . value ;
617613 if ( cancelledDateValue ) {
618- // Create date in local timezone to avoid timezone offset issues
614+ // Create date at noon UTC to avoid timezone edge cases
619615 const [ year , month , day ] = cancelledDateValue
620616 . split ( "-" )
621617 . map ( Number ) ;
622618 const newCancelledDate = new Date (
623- year ,
624- month - 1 ,
625- day
619+ Date . UTC ( year , month - 1 , day , 12 , 0 , 0 )
626620 ) . getTime ( ) ;
627621 // Only update if the date has changed or is different from the original
628622 if ( task . metadata . cancelledDate !== newCancelledDate ) {
0 commit comments