neos-ui
neos-ui copied to clipboard
BUGFIX: Fix handling of 'now' in DateTime Editor
What I did fixes #3391
How I did it Enabled DateTimeEditor to handle 'now' string. Built tests for that 🚀
How to verify it See instructions in #3391.
Run tests.
but I honestly can’t see a usecase and find date default values odd in general. Why would you use them???
Just because we can't see besides a use case except 'now' doesm't mean there is none. If in your editing process, some news for example, always have to be published on a defined time it would be quite helpful to define this as default. This would reduce the need to use the datepicker.
We can use something like the PHP strtotime
in JavaScript to achieve the same compatibility.
Have a quick sandbox. We just need to put that into TS and add some tests 🙈
https://codesandbox.io/s/ancient-night-iut33c?file=/src/index.js
As the field should support all this. https://neos.readthedocs.io/en/8.3/References/PropertyEditorReference.html?highlight=Datetime#property-type-datetime-datetimeeditor-date-time-selection-editor
First try of migrating that to TS... need to more love and tests.... But looks promising
https://codesandbox.io/s/peaceful-snowflake-b0k4p2?file=/src/index.ts
First try of migrating that to TS... need to more love and tests.... But looks promising
https://codesandbox.io/s/peaceful-snowflake-b0k4p2?file=/src/index.ts
I think I'd rather build an endpoint for that and let this string
to date
conversion be handled by the Server.
Re-implementing the strtotime
of PHP in TS feels weird and we would have 2 different solutions doing the same thing wich will get us into trouble in the future.
What is your take on time zone? Should it be the time zone of the server or the client? Right now it's always the time zone of the server right?
Might be more complex then initially assumed: #3391 (comment)
but I honestly can’t see a usecase and find date default values odd in general. Why would you use them???
Imagine you want to build a NodeType with a Date that defaults to "Tomorrow" or "This day next week at 9am". I believe this is one use case that requires that kind of complexity.
I didn't know this when we implemented the fix 🙈