fellinga / node-red-contrib-ui-time-scheduler

Easily power on/off any kind of device based on a schedule that you can easily create at the node-red-dashboard frontend.
MIT License
37 stars 15 forks source link

Scheduler yields incorrect days for local time #102

Open camx opened 2 months ago

camx commented 2 months ago

If I enter a time beyond the UTC-Local time midnight difference the scheduler returns the wrong day. That sounds cryptic to me, and I wrote it, so let me give an example.

My local time difference is UTC-5. Say it is Sun and I schedule a time span [19:00, 19:03] then the issued schedule is for the next day, Mon, instead of today.

A time span [18:59, 1903] is scheduled for the correct day. The threshold value is the difference between UTC and Local time, 24:00-5:00 = 19:00.

I haven't tested it, but I suspect the timer outputs (as opposed to the schedule: output 1), function correctly.

image

{"timers":[{"starttime":1719187200000,"days":[0,1,0,0,0,0,0],"output":"0","endtime":1719187320000}],"settings":{}} which should be ... "days":[1,0,0,0,0,0,0],...

starttime and endtime are also displaced to the next day instead of the current one.

fellinga commented 2 months ago

Hi @camx,

yes you are right. The days array ("days":[...]) stores its values in UTC time. It then recalculates the execution time based on your local time.

This makes sure that you will always see the correct time in your browser. Just image the following scenario: You create a schedule in your Node Red instance in your browser (UTC-5) at Sunday 19:00 to 19:05 - you would see exactly that. If I would then open your Node Red instance in my browser (UTC+1) it then would display Monday 01:00 to 01:05.

Let me know if you have any questions!