A question about "Simpletime"

last year I used the "Simpletime" node. I remember using the following code:

if(msg.mymonthn>=4||(msg.mymonthn<=10&&msg.mydom<27)){//adjust based on Daylight savings time

I am trying to recreate it at the moment, but having issues. The node has changed. Now I want to know if the node uses the computer time?

I remember having to adjust for DST, but now I don't (testing locally). Also I remember when I added an hour it actually took away an hour. Can anyone help with clarifying as the documentation doesn't say where the source of time is from.

Simpletime uses, and has always used Date() to determine the base time, on which the calculations are based.
Which in turn uses the user's local (browser's) timezone.
No changes have been made to this since the node was first written, so it's likely that at some stage your system has changed to respect your current timezone. Is that likely?

You shouldn't have to provided the timezone is correctly set on the node-red machine, and the time is set correctly.

I don't think that code will actually work for at least 2 reasons anyway;

  1. The values from Simpletime are all strings, not numbers, so if the hour was 15, and the calculation was msg.myhour+=1; wouldn't the resulting value be 151?
  2. Again if the hour was 15, and you added an hour from msg.myhour (+=1) the result would be 16, whilst subtracting an hour from msg.myhour (-=1) would result in 14.
    Meaning that there is a 2hr difference between GMT & IST(BST) which is incorrect.

Thats the thing. they are strings but I remeber when I tested it I had it working last year. Maybe I'm wrong.

I understand the logic of addition and subtracting, just for some reason when I tested it I remember it working.

Are you getting the wrong times out of the node? It should take DST into account.

Not now. But when I tested it last year I was using IBM's version of node-red(hosted in London) and I remember having to adjust for DST. At the moment I'm not having that issue.

The system probably had the wrong timezone configured.

Thanks for the explanation and clarification.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.