react-jsonschema-form
react-jsonschema-form copied to clipboard
Format time in compliance with Draft 7
Prerequisites
- [X] I have searched the existing issues
- [X] I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [X] I have read the documentation
- [ ] Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
mui
Version
5.13.0
Current Behavior
The WidgetTime currently outputs time in the format 20:20:39
without including a timezone offset
Expected Behavior
According to JSON Schema Draft 7 compliance, the WidgetTime should output time with a timezone to be considered valid. The time format should include a timezone offset, something like 20:20:39+00:00
Steps To Reproduce
Use the playground
{
"title": "Date and time widgets",
"type": "object",
"properties": {
"time": {
"type": "string",
"format": "time"
}
}
}
Environment
- OS: MacOS 13.2.1
- Node: v16.20.2
- npm: 8.19.4
Anything else?
A quick solution is to override WidgetTime with a custom one.
I think there are two issues here:
- Whether the widget shows (and maybe lets you change) timezone
- Whether the formData time has a properly formatted timezone
I think we might have to solve the formData issue before the widget issue. It would be great to be in compliance with the JSONSchema spec but I think this could be a breaking change for anyone who uses time fields. I think we could put it in v5 with a feature flag and make it the default behavior in v6.
Once we properly support time zones, a TZ picker could be added to the widget, or we could add another widget to @rjsf/core to support that use case.
PRs are welcome to improve this issue!