@@ -960,13 +960,36 @@ export class DeepnoteInputBlockCellStatusBarItemProvider
960960 this . _onDidChangeCellStatusBarItems . fire ( ) ;
961961 }
962962
963+ /**
964+ * Convert a date value to YYYY-MM-DD format without timezone shifts.
965+ * If the value already matches YYYY-MM-DD, use it directly.
966+ * Otherwise, use local date components to construct the string.
967+ */
968+ private formatDateToYYYYMMDD ( dateValue : string ) : string {
969+ if ( ! dateValue ) {
970+ return '' ;
971+ }
972+
973+ // If already in YYYY-MM-DD format, use it directly
974+ if ( / ^ \d { 4 } - \d { 2 } - \d { 2 } $ / . test ( dateValue ) ) {
975+ return dateValue ;
976+ }
977+
978+ // Otherwise, construct from local date components
979+ const date = new Date ( dateValue ) ;
980+ const year = date . getFullYear ( ) ;
981+ const month = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) ;
982+ const day = String ( date . getDate ( ) ) . padStart ( 2 , '0' ) ;
983+ return `${ year } -${ month } -${ day } ` ;
984+ }
985+
963986 /**
964987 * Handler for date input: choose date
965988 */
966989 private async dateInputChooseDate ( cell : NotebookCell ) : Promise < void > {
967990 const metadata = cell . metadata as Record < string , unknown > | undefined ;
968991 const currentValue = metadata ?. deepnote_variable_value as string | undefined ;
969- const currentDate = currentValue ? new Date ( currentValue ) . toISOString ( ) . split ( 'T' ) [ 0 ] : '' ;
992+ const currentDate = currentValue ? this . formatDateToYYYYMMDD ( currentValue ) : '' ;
970993
971994 const input = await window . showInputBox ( {
972995 prompt : l10n . t ( 'Enter date (YYYY-MM-DD)' ) ,
@@ -1004,8 +1027,8 @@ export class DeepnoteInputBlockCellStatusBarItemProvider
10041027 let currentEnd = '' ;
10051028
10061029 if ( Array . isArray ( currentValue ) && currentValue . length === 2 ) {
1007- currentStart = new Date ( currentValue [ 0 ] ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
1008- currentEnd = new Date ( currentValue [ 1 ] ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
1030+ currentStart = this . formatDateToYYYYMMDD ( currentValue [ 0 ] ) ;
1031+ currentEnd = this . formatDateToYYYYMMDD ( currentValue [ 1 ] ) ;
10091032 }
10101033
10111034 const input = await window . showInputBox ( {
@@ -1049,8 +1072,8 @@ export class DeepnoteInputBlockCellStatusBarItemProvider
10491072 let currentEnd = '' ;
10501073
10511074 if ( Array . isArray ( currentValue ) && currentValue . length === 2 ) {
1052- currentStart = new Date ( currentValue [ 0 ] ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
1053- currentEnd = new Date ( currentValue [ 1 ] ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
1075+ currentStart = this . formatDateToYYYYMMDD ( currentValue [ 0 ] ) ;
1076+ currentEnd = this . formatDateToYYYYMMDD ( currentValue [ 1 ] ) ;
10541077 }
10551078
10561079 const input = await window . showInputBox ( {
0 commit comments