@@ -152,8 +152,12 @@ export function tooltipText(
152152 }
153153
154154 if ( observation_value_error === null && age_error === null ) {
155+ const year = observation_date . split ( '/' ) [ 2 ]
156+ const month = observation_date . split ( '/' ) [ 1 ] - 1
157+ const day = observation_date . split ( '/' ) [ 0 ]
158+
155159 // sds in square brackets
156- const formatted_observation_date = new Date ( observation_date ) . toLocaleDateString ( "en-GB" , { year : "numeric" , month : "short" , day : "numeric" } ) ;
160+ const formatted_observation_date = new Date ( year , month , day ) . toLocaleDateString ( "en-GB" , { year : "numeric" , month : "short" , day : "numeric" } ) ;
157161 const sds_string = `[SDS: ${ sds > 0 ? '+' + Math . round ( sds * 1000 ) / 1000 : Math . round ( sds * 1000 ) / 1000 } ]` ;
158162 if ( age_type === 'corrected_age' && x > 0.0383 ) {
159163 const finalCorrectedString = comment . replaceAll ( ', ' , ',\n' ) . replaceAll ( '. ' , '.\n' ) ;
@@ -173,8 +177,11 @@ export function tooltipText(
173177 // <= 42 weeks
174178 /// plots
175179 if ( observation_value_error === null ) {
180+ const year = observation_date . split ( '/' ) [ 2 ]
181+ const month = observation_date . split ( '/' ) [ 1 ] - 1
182+ const day = observation_date . split ( '/' ) [ 0 ]
176183 // && age_error === null temporarily removed from if statement as error in api return object for EDD < observation_date
177- const formatted_observation_date = new Date ( observation_date ) . toLocaleDateString ( "en-GB" , { year : "numeric" , month : "short" , day : "numeric" } ) ;
184+ const formatted_observation_date = new Date ( year , month , day ) . toLocaleDateString ( "en-GB" , { year : "numeric" , month : "short" , day : "numeric" } ) ;
178185 let corrected_gestational_age = ''
179186 if ( gestational_age ) {
180187 corrected_gestational_age = `${ gestational_age . corrected_gestation_weeks } +${ gestational_age . corrected_gestation_days } weeks`
0 commit comments