Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Input node set for 'datetime picker' with a value passed to the input node breaks the picker #1409

Open
gfinleyg opened this issue Oct 17, 2024 · 13 comments
Labels
bug Something isn't working needs-triage Needs looking at to decide what to do

Comments

@gfinleyg
Copy link

Current Behavior

Inputs to a Text Input node that is set to datetime picker aren't displayed.

Expected Behavior

Passing a valid JavaScript Date number should change the date and time set in the field.

Steps To Reproduce

Attach a function block outputting msg.payload = 1728932496400 to the input of a Text Input node with it's mode set to datetime picker.

Environment

  • Dashboard version: 2.0
  • Node-RED version: v4.0.5
  • Node.js version: v20.18.0
  • npm version: 10.0.9
  • Platform/OS: Linux 5.14.0-430.el9.x86_64 x64 LE
  • Browser: Firefox 131.0.2 (64-bit)

Have you provided an initial effort estimate for this issue?

I am not a FlowFuse team member

@gfinleyg gfinleyg added bug Something isn't working needs-triage Needs looking at to decide what to do labels Oct 17, 2024
@gfinleyg
Copy link
Author

The node's behavior is broken with this setup too, if you try to change any of the date/time fields or select using the calendar, it goes back to a blank value as soon as you mouse-hover over the field again.

@bartbutenaers
Copy link
Contributor

@gfinleyg

  • Indeed when I inject 1728932496400 as payload, it doesn't appear in the datetimepicker. And in my developer tools console log, I see this error:
    The specified value "1729797008798" does not conform to the required format. The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS".
    I could change the code to fix it, but would like to hear first the core devs their opinion whether that is desired behaviour.

  • I also can confirm that the selected datetime disappears in Firefox on my Windows 10 portable. For Chrome and Edge this problem does not occur.
    I don't see any errors in the Firefox console log.

@gfinleyg
Copy link
Author

I was trying it with a numerical value of 1728932496400, it's good to note that the string "1728932496400" doesn't work either.

I also tried a few of the Javascript "new Date()" formats, with no luck.

It looks like using the format that you saw in the dev tools console log works and doesn't leave the tool broken in Firefox. It appears that the .toISOString() function would get that output, but none of the other formats will work out of the box and .toISOString() isn't available in my instance of Node-Red for function nodes.

@colinl
Copy link
Contributor

colinl commented Oct 24, 2024

I think the idea is that you have to feed it with a value in the same format as the output.
If you want it to take a js timestamp then it has to know which timezone you want, which can be problematic. As it is, it is timezone agnostic. D1 is a bit of a mess with time/date pickers because of this.
Edit: A mess because it tries to allow for timezone.

@gfinleyg
Copy link
Author

@colinl That makes sense, but it isn't returned in that format and there isn't any documentation of how it should work in https://dashboard.flowfuse.com/nodes/widgets/ui-text-input.html. A working datetime output looks like:
12/01/2024, 01:01 AM
not
"yyyy-MM-ddThh:mm"

I'm not sure where to get access to the developer tools console log mentioned earlier, so I had no idea that was the format required for this to work.

I figured the varying format possibilities could be a problem which was why I started with the numerical ms since the beginning of the Epoch input.

@colinl
Copy link
Contributor

colinl commented Oct 24, 2024

but it isn't returned in that format

It is for me.
image

@gfinleyg
Copy link
Author

gfinleyg commented Oct 24, 2024

Fair, I was looking at the output on the dashboard rather than a debug node. I suppose not using the ms since the beginning of the epoch also allows usage of dates before 1970 which could have some use-cases.

Looks like you can use negative numbers to set dates prior to 1970, so that last statement isn't as important.

@Steve-Mcl
Copy link
Contributor

Steve-Mcl commented Nov 11, 2024

Inputs to a Text Input node that is set to datetime picker aren't displayed.

They are if you send a well formatted date / time / datetime

See the "Try Demo" link in the docs: https://dashboard.flowfuse.com/nodes/widgets/ui-text-input.html

Related: https://discourse.nodered.org/t/default-values-in-text-input/93073


@joepavitt we may wish to relax this as it took me too long to determine the correct format. We should take anything that "looks like a date/time/datetime" and use it. As it stands, sending 2024-11-11 10:15 into a date is rejected, sending 2024-11-11 into a datetime is rejected - I see no reason to be so strict here?. We should also accept valid Epoch and perhaps Unix timestamp too. However, I do expect complications where timezones are concerned.

@colinl
Copy link
Contributor

colinl commented Nov 11, 2024

Be very careful here, I suggest not allowing anything where timezones may come into play, otherwise we will end up in the same mess as with D1. Currently the input has to be in the same form as the output, which is TZ agnostic and there is no confusion about what it means. That means, I think, that milliseconds, date/time with timezone specified, etc should not be allowed.

@gfinleyg
Copy link
Author

@colinl Using milliseconds is setting it based on unix time which is always tied to UTC. There's no time zone to worry about with it.

@colinl
Copy link
Contributor

colinl commented Nov 11, 2024

Using milliseconds is setting it based on unix time which is always tied to UTC. There's no time zone to worry about

Suppose I have an Inject node configured to send the current time in milliseconds, feeding into the datetime picker node. If I look at my watch and it says 12:00 and I click the Inject node, what time would you expect it to set the picker to?

@gfinleyg
Copy link
Author

@colinl That would be whatever difference you have between your Time Zone at 12:00 and UTC. When I said you don't need to worry about time zones I meant as far as parsing the input. If a developer is planning to use unix time as an input I would expect them to understand how that works.

@colinl
Copy link
Contributor

colinl commented Nov 11, 2024

If a developer is planning to use unix time as an input I would expect them to understand how that works.

Remember that node-red is aimed at users that are not software developers. The inject node sends the current time, but if you feed that into the datetime node it would generally not display what the user considers to be the current time. Such issues cause endless confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Needs looking at to decide what to do
Projects
Status: Backlog
Development

No branches or pull requests

4 participants