Skip to content

(ADO-3242) Date format YYYY-MM-DD into MM/DD/YYYY for save ICM data#90

Merged
bzimonjaSDPR merged 1 commit into
devfrom
ADO-3242
Aug 25, 2025
Merged

(ADO-3242) Date format YYYY-MM-DD into MM/DD/YYYY for save ICM data#90
bzimonjaSDPR merged 1 commit into
devfrom
ADO-3242

Conversation

@NicolaSDPR1
Copy link
Copy Markdown
Collaborator

Commit: create a date converter and change date format to ICM required format for XML conversion

What changes did you make?

Added a file called dateConverter.js that contains a function which converts a string in date format YYYY-MM-DD to a string in date format MM/DD/YYYY.

Updated saveICMdataHandler.js to find all the fields using type: date, and then updated the date format to the above ICM required MM/DD/YYYY with the function.

Why did you make these changes?

As per https://dev.azure.com/BC-SDPR/Forms%20Modernization/_workitems/edit/3232, ICM requires date fields have their format be MM/DD/YYYY. The form data uses YYYY-MM-DD, which is currently not acceptable for ICM. Updating the dates to use MM/DD/YYYY when translated to XML version should fix this.

Child date field ids do not include their parent UUIDs while comparing the found field type, which is why there's a substring check: dateItemsId.includes(oldChildKey.substring(stringLength+3, childStringLength))

What alternatives did you consider?

I considered using a pattern match to update date fields to new format, however that ran the risk up updating non-date field types. By finding the date field ids first and then applying format changes during the UUID change, this meant there was no additional looping happening to overwrite the fields and no problem matching UUIDs with the date field ids found.

There is an error handling for the function when a date input does not met requirements (i.e. cannot be separated into Year, Month, Day for re-formatting). This sets the return values as -1 because there is a chance of date fields being null within the json/form.

Checklist

  • I have assigned at least one reviewer
  • My code meets the style guide
  • My code has adequate test coverage (if applicable)

@bzimonjaSDPR bzimonjaSDPR merged commit dfadd5e into dev Aug 25, 2025
3 checks passed
@bzimonjaSDPR bzimonjaSDPR deleted the ADO-3242 branch August 25, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants