govuk-prototype-kit
govuk-prototype-kit copied to clipboard
Users find it hard to work with dates
What
The ability to show todays date, or to manipulate and format dates (for example a date 30 days from today, formatted in the GOV.UK style for dates)
Should this feature support different types of date format? Or just the GOV.UK style? What would the MVP be? Today's date? Could this be a GOV.UK date plugin?
This is a time boxed spike Initially a day would be spent investigating possible solutions. If more time is needed, it must be discussed and agreed first before work continues.
Why
Because this is something users struggle with and it comes up fairly regularly in support.
Who
- Developer
- Designer
Done when
- [ ] Possible solutions are shown to the team
- [ ] The next step(s) are identified
- [ ] New ticket(s) are created
We've got lots of filters for working with dates - happy to contribute. Current versions are here - though they're currently using Moment and I know you'd prefer a supported library. Any preference on library?
Some of the common things I use filters for:
Formatting dates in GOV.UK style
Convert a javascript date to string
2021-05-28T17:21:36.307Z
to 28 May 2021
Convert an array of integers to string (as produced by govukDateInput)
[1,2,2020]
to 1 February 2020
Converting dates to arrays of integers
Useful where you want to populate a govukDateInput with an existing date
28 May 2021
to [28,5,2021
General purpose checks
isInFuture
isInPast
isInLast(x, period)
- check if date is within x period
Just to note this has come up regularly in support recently
there are some date filters in the X-GOVUK filter plugin: https://x-govuk.github.io/govuk-prototype-filters/date/
https://github.com/alphagov/govuk-prototype-kit-docs/pull/266