Add filter to format date object into a readable date
Description
For the formatting of dates on the check your answers page in a prototype, I came across this this useful Nunjucks filter to change a number, like 1 "12" or 04, to a month in words: https://github.com/nhsuk/permission-to-contact-prototype/blob/master/app/filters.js#L12
I think this would be useful adding to main prototype kit?
This would help prototypes (and therefore services) meet the Dates guidance:
As far as possible, spell out months in full. Screen readers read out shortened months (Jan, Feb and so on) in inconsistent and sometimes confusing ways.
Good idea @chrimesdev 👏🏻
That code looks like something I wrote up for the app prototype ages ago. So I am sure there's a smarter way of writing it. The reason we wrote it was we were redesigning the appointment booking service.
We constantly needed to convert what was inputted into dates and reflected back to the user. So we needed the filter. It saved a load of code in each template file.
https://github.com/GrilloPress/contact-preference/blob/master/app/filters.js#L165
This filter: govukDate does something similar (but with a whole date rather than just the month number) - and can be added to NHS prototypes like this: https://github.com/NHSDigital/record-a-vaccination-prototype/blob/main/app/filters.js#L2-L11
It might still be worth considering importing this (and renaming to nhsDate?) and making it available as a core filter though, given dates are such a common field type to prototype?