Skip to content

Commit f276193

Browse files
authored
Merge pull request #69 from rcpch:eatyourpeas/issue68
refactor date label
2 parents 92633ee + a85f16d commit f276193

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rcpch/digital-growth-charts-react-component-library",
3-
"version": "6.1.13",
3+
"version": "6.1.14",
44
"main": "build/index.js",
55
"module": "build/index.esm.js",
66
"files": [

src/functions/tooltips.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,18 @@ export function tooltipText(
153153

154154
if (observation_value_error === null && age_error === null) {
155155
// sds in square brackets
156-
156+
const formatted_observation_date = new Date(observation_date).toLocaleDateString("en-GB", {year: "numeric", month: "short", day: "numeric"});
157157
const sds_string = `[SDS: ${sds > 0 ? '+' + Math.round(sds*1000)/1000 : Math.round(sds*1000)/1000 }]`;
158158
if (age_type === 'corrected_age' && x > 0.0383) {
159159
const finalCorrectedString = comment.replaceAll(', ', ',\n').replaceAll('. ', '.\n');
160-
return `Corrected age: ${calendar_age} on ${observation_date}\n${finalCorrectedString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
160+
return `Corrected age: ${calendar_age} on ${formatted_observation_date}\n${finalCorrectedString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
161161
}
162162
if (age_type === 'chronological_age') {
163163
let finalChronologicalString = comment
164164
.replaceAll(', ', ',\n')
165165
.replaceAll('. ', '.\n')
166166
.replaceAll('account ', 'account\n');
167-
return `Chronological age: ${calendar_age} on ${observation_date}\n${finalChronologicalString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
167+
return `Chronological age: ${calendar_age} on ${formatted_observation_date}\n${finalChronologicalString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
168168
}
169169
}
170170
// measurement data points
@@ -174,6 +174,7 @@ export function tooltipText(
174174
/// plots
175175
if (observation_value_error === null ) {
176176
// && 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"});
177178
let corrected_gestational_age=''
178179
if (gestational_age){
179180
corrected_gestational_age=`${gestational_age.corrected_gestation_weeks}+${gestational_age.corrected_gestation_days} weeks`
@@ -182,11 +183,11 @@ export function tooltipText(
182183
const sds_string = `[SDS: ${sds > 0 ? '+' + Math.round(sds*1000)/1000 : Math.round(sds*1000)/1000 }]`;
183184
if (age_type === 'corrected_age') {
184185
const finalCorrectedString = comment.replaceAll(', ', ',\n').replaceAll('. ', '.\n');
185-
return `${calendar_age}\nCorrected age: ${corrected_gestational_age} on ${observation_date}\n${finalCorrectedString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
186+
return `${calendar_age}\nCorrected age: ${corrected_gestational_age} on ${formatted_observation_date}\n${finalCorrectedString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
186187
}
187188
if (age_type === 'chronological_age') {
188189
let finalChronologicalString = comment.replaceAll(', ', ',\n').replaceAll('. ', '.\n');
189-
return `Chronological age: ${calendar_age}\n${observation_date}\n${finalChronologicalString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
190+
return `Chronological age: ${calendar_age}\n${formatted_observation_date}\n${finalChronologicalString}\n${y} ${measurementSuffix(measurementMethod)} ${ clinicianFocus ? sds_string : '\n' + finalCentile}`;
190191
}
191192
}
192193
}

0 commit comments

Comments
 (0)