Skip to content

Commit 0c306b0

Browse files
authored
Merge pull request #73 from rcpch:eatyourpeas/issue72
Incorrect date parse in observation_date tooltip
2 parents f276193 + 35af103 commit 0c306b0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Diff for: package.json

+1-1
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.14",
3+
"version": "6.1.15",
44
"main": "build/index.js",
55
"module": "build/index.esm.js",
66
"files": [

Diff for: src/functions/tooltips.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)