mrgadget / node-red-contrib-eztimer

A simple-yet-flexible timer/scheduler for node-red
MIT License
13 stars 6 forks source link

localtime instead of UTC #29

Closed Bond246 closed 4 years ago

Bond246 commented 4 years ago

Hello,

is it possible to use the localtime (timezone) instead of UTC?

Thanks

mrgadget commented 4 years ago

Hi,

The timer does indeed use local time (not UTC) - If you're seeing what appears to be UTC then I'd suggest that it's either lat/long set wrong (causing sun events from the other side of the world - I've had this, because we're at GMT+12 so it looked like everything was UTC), or your node-red box is using UTC possibly?

Let me know how you get on.

Bond246 commented 4 years ago

Hi Ben,

my NodeRed is running inside docker with throughpassed time and zone. My Time is Berlin, so acutally CEST (+2).

bash#: date -R inside the docker container gives the correct actual CEST time. Tue, 07 Apr 2020 13:06:36 +0200

My eztimer was configured to use "Time of Day" so there is no option for setting lat/long. Using the following nodes is configured for 11:06 > on and 11:07 > off. But the output is generated on 13:06 and 13:07: [{"id":"800eabbd.f76528","type":"eztimer","z":"29164644.6b19ea","name":"kuechenradio - Alltag","debug":true,"autoname":"11:06:00 - 11:07:00","tag":"eztimer","suspended":false,"sendEventsOnSuspend":false,"lat":"","lon":"","timerType":"1","startupMessage":false,"ontype":"2","ontimesun":"dawn","ontimetod":"11:06:00","onpropertytype":"msg","onproperty":"payload","onvaluetype":"str","onvalue":"play","onoffset":0,"onrandomoffset":0,"onsuppressrepeats":false,"offtype":"2","offtimesun":"dusk","offtimetod":"11:07:00","offduration":"00:01:00","offpropertytype":"msg","offproperty":"payload","offvaluetype":"str","offvalue":"stop","offoffset":0,"offrandomoffset":0,"offsuppressrepeats":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"sun":false,"x":280,"y":200,"wires":[["58851764.27f3c8"]]},{"id":"58851764.27f3c8","type":"debug","z":"29164644.6b19ea","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":540,"y":200,"wires":[]}]

The log after generating the Schedule-Event is without GMT+2: Scheduled 'ON' (time of day) for Tue Apr 07 2020 11:06:00 GMT+0000 Scheduled 'OFF' (time of day) for Tue Apr 07 2020 11:07:00 GMT+0000

mrgadget commented 4 years ago

That's really odd. It seems like somehow moment.js is being told to use GMT on your system.

If I import your test nodes and hit deploy (making no change) I get the following output: image Which shows it in local time. There's no configuration options around time within my node - all time is just picked up from nodered/node.js in turn from the system.

Incidentally mine is also running within docker (on a home assistant platform).

I'm not sure exactly where to go from here - open to suggestions - but it still looks to me like there's a UTC flag set either at a base OS, node.js or nodered level.

Bond246 commented 4 years ago

ok thanks! i think based on this i can play around with some configurations in my container landscape. Maybe i found a solution for this.

Its my first scheduler inside NodeRed so i didn't had that problem before.

Bond246 commented 4 years ago

The solution was really simple: using -e TZ=Europe/Berlin as environmental variable will solve my problem. Didn't used this option cause i hadn't known about it.

Thanks for your support!

mrgadget commented 4 years ago

Great! Pleased it was straight forward to solve, and thanks for posting back here with the solution - will no doubt help others.