bartbutenaers / node-red-contrib-blockly

A Node Red node for visual programming a function using Blockly
Apache License 2.0
89 stars 22 forks source link

Avoid duplicate 'new Date(....)' coding #37

Closed bartbutenaers closed 5 years ago

bartbutenaers commented 6 years ago

The datetime_convert_from_date block has most of the time a timestamp as input: image

Which generates this code: image

At the start we have 2 times a new Date, because the timestamp block generates already a Data object instance (as new Date() ).

Would like to avoid this by putting in the code generator something like this: IF input connected to an output that has type 'Date' Just use the input ELSE put an extra new Date( .. ) around it

But need some feedback first from the Blockly forum to get this solved:

bartbutenaers commented 5 years ago

Obsolete issue since the input timestamp is currently a number (instead of a date). So we need to convert that number to a date anyway.