Let's take a look at this JSON response:
{
data: {
nestedData: {
someMoreNestedData: {
someArray: [
{
someWhereThereIsADate: '2018-10-26'
}
]
},
wholeBunchOfOtherData: {...}
}
}
}
Currently, the date format is 'yyyy-MM-dd', but it could change to something like 'yyyyMMdd' or 'MM/dd/yyyy' in the future.
The UI currently displays dates in 'MM/dd/yyyy', but this may need to be adaptable for different formats down the line.
Instead of having one function handling both parsing and formatting dates, we can consider splitting this into two separate functions. This separation might make it more challenging to efficiently handle scenarios where the input and output formats are the same.
Another approach could involve converting the JSON response into a data object with Dates instead of strings, but this option might introduce performance overhead.
If anyone has encountered similar challenges and devised best practices, I'd love to hear about them!