You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Blockly to try to create a datetime object at exactly midday today, everything works except decimal part of the time (milli / micro / nanoseconds).
Produces this code:
Setting 1 millisecond creates the code correctly, but 0 milliseconds fails.
This is the datetime object created:
2025-05-10T12:00:00.809+02:00[Europe/Zurich]
I imagine this is a divide by zero type error.
Trying to do the same thing using the "datetime with date" block:
Produces the datetime object like this (Note the missing minutes):
2025-05-10T12:00+02:00[Europe/Zurich]
But the code looks good (to me): midday = time.ZonedDateTime.now().withYear(((time.ZonedDateTime.now()).year())).withMonth(((time.ZonedDateTime.now()).monthValue())).withDayOfMonth(((time.ZonedDateTime.now()).dayOfMonth())).withHour(12).withMinute(0).withSecond(0).withNano(0); console.log(midday);
Expected behavior
After running the above, I would expect the z-datetime object to be exactly midday
2025-05-10T12:00:00.000+02:00[Europe/Zurich]
Steps to reproduce
This is a sample rule that can be used to show the issue:
@Little-Hobo FYI I am already on that one but it turns out to be much more complicated as it seems to be. The reason is that setting the Nanos includes not only the nanos but also the millis and micros in the underlying API. So I need to implement some clever logic that merges your blocks internally and prevents overwriting.
Uh oh!
There was an error while loading. Please reload this page.
When using Blockly to try to create a datetime object at exactly midday today, everything works except decimal part of the time (milli / micro / nanoseconds).
Produces this code:
Setting 1 millisecond creates the code correctly, but 0 milliseconds fails.
This is the datetime object created:
2025-05-10T12:00:00.809+02:00[Europe/Zurich]
I imagine this is a divide by zero type error.
Trying to do the same thing using the "datetime with date" block:

Produces the datetime object like this (Note the missing minutes):
2025-05-10T12:00+02:00[Europe/Zurich]
But the code looks good (to me):
midday = time.ZonedDateTime.now().withYear(((time.ZonedDateTime.now()).year())).withMonth(((time.ZonedDateTime.now()).monthValue())).withDayOfMonth(((time.ZonedDateTime.now()).dayOfMonth())).withHour(12).withMinute(0).withSecond(0).withNano(0); console.log(midday);
Expected behavior
After running the above, I would expect the z-datetime object to be exactly midday
2025-05-10T12:00:00.000+02:00[Europe/Zurich]
Steps to reproduce
This is a sample rule that can be used to show the issue:
`configuration: {}
triggers: []
conditions: []
actions:
inputs: {}
id: "1"
configuration:
blockSource: middaymiddaywith2025-05-0212middaywith2025-05-02midday0middaywith2025-05-02midday0middaywith2025-05-02midday0abcmidday
type: application/javascript
script: |
var midday;
type: script.ScriptAction
`
Your environment
Browser console
Cannot see any errors in browser console.
Browser network traffic
Cannot see any errors in browser console network.
The text was updated successfully, but these errors were encountered: