neos-ui icon indicating copy to clipboard operation
neos-ui copied to clipboard

BUGFIX: Fix handling of 'now' in DateTime Editor

Open JamesAlias opened this issue 2 years ago • 5 comments

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.

Screenshot 2023-02-23 at 11 38 00 AM

JamesAlias avatar Feb 23 '23 10:02 JamesAlias

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.

ahaeslich avatar Feb 23 '23 11:02 ahaeslich

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

markusguenther avatar Feb 24 '23 10:02 markusguenther

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

markusguenther avatar Feb 24 '23 12:02 markusguenther

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?

JamesAlias avatar Feb 28 '23 09:02 JamesAlias

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 🙈

JamesAlias avatar Feb 28 '23 09:02 JamesAlias