curveball / browser

A HAL browser middleware for node.js
MIT License
43 stars 5 forks source link

Fix the datetime-local value #151

Closed mhum closed 1 year ago

mhum commented 1 year ago

The value that goes into the datetime-local field shouldn't have a timezone. This strips off the Z that gets added to the end.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local#value

There are several methods provided by JavaScript's Date that can be used to convert numeric date information into a properly-formatted string. For example, the Date.toISOString() method returns the date/time in UTC with the suffix "Z" denoting that timezone; removing the "Z" would provide a value in the format expected by a datetime-local input.

Would it be possible to also backport this to v0.18.0? I'd like to be able to delivery this fix without needing to update everything to require @curveball/kernel

evert commented 1 year ago

Very happy with this fix! I saw weird datetime-local issues before and I'm curious if this was why

mhum commented 1 year ago

Very happy with this fix! I saw weird datetime-local issues before and I'm curious if this was why

Depends on what you saw! What I was seeing was that the input wouldn't have the value set. image

and then on POST when submitting the form, it wouldn't send a value back image