Belchertown skin - dark theme switchover around sunset

128 views
Skip to first unread message

Eric K

unread,
Mar 26, 2022, 4:39:08 PM3/26/22
to weewx-user
I have the Belchertown skin theme set to "auto" so it switches over to the dark theme around sunset.
I have noted that the Belchertown skin switches over to the dark theme at large fractions of an hour before sunset actually occurs.
Then, I got a report from a friend in the Eastern time zone, that the webpage theme switched to dark around 6:00pm Eastern time - around 2 hours early compared to the local sundown time (7:39pm Central) at my weewx weather station.
He said he had not clicked the manual theme switch at the upper right corner of the Belchertown page.

So, I started looking through the code to see how the theme change gets triggered.


Around line 507 the current hour and minute get assigned to variables with the expressions 
var nowHour = d.getHours();
var nowMinutes = d.getMinutes();
Where is the time being read from?
1. from the clock of the computer that weewx is running inside?
2. from the clock of webpage visitor's computer?

Doug Jenkins

unread,
Mar 26, 2022, 7:37:08 PM3/26/22
to weewx...@googlegroups.com
I think it is from the local client. The JavaScript is executed in the browser. 

We need to see where "D" is initialized to make sure it is not using a web api to obtain the time

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/7eb9e891-52a4-4e1f-9e04-e322bb2460bcn%40googlegroups.com.

Eric Koester

unread,
Mar 27, 2022, 12:33:58 PM3/27/22
to weewx...@googlegroups.com
I gave a link to the file so you could look at it:  

There is a definition of a "var d" at line 507.
var d = new Date();

I still can't tell where it's getting its time from.

You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/WfhDmYJZZZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CACC0i0xDXGaD0%2BZZ0E-Cu3W6eo_QDOpbxoZ5m0tbe3OxKiCCAg%40mail.gmail.com.

vince

unread,
Mar 27, 2022, 12:54:43 PM3/27/22
to weewx-user
Easiest thing to do is figure it out experimentally.    Connect into a Belchertown site on the other side of the ocean and see.

Doug Jenkins

unread,
Mar 27, 2022, 3:28:59 PM3/27/22
to weewx...@googlegroups.com
I looked at the code and yes, this is running on the client side. This means the light/dark mode is determined y checking the person's web browser and seeing if it is out of the range of sunrise hours. 

If it is, then the JavaScript changes the theme to dark, otherwise it remains on light.

So what this means if it is midnight where your weather station is on the east coast of the US, a user in Tokyo (+13 hours) is going to see the light theme of he goes to your weather website.

Probably what should happen here is the script is fed the server time as a constant when the cheetah generator "creates" this script upon execution of StdReport. Then the code will evaluate that datevalue to determine if the theme should change.

If there is any interest on this item, I recommend putting in an issue on the GitHub project and send it to me. I can do an update and submit a PR with the correction.

Doug Jenkins

Eric Koester

unread,
Mar 27, 2022, 4:12:01 PM3/27/22
to weewx...@googlegroups.com
Thanks for looking at this, Doug.

"Probably what should happen here is the script is fed the server time as a constant when the cheetah generator "creates" this script upon execution of StdReport. Then the code will evaluate that datevalue to determine if the theme should change."
Until my Eastern time zone friend reported otherwise, I expected that this was the default behavior.

I suspect you are talking about this Github project page?
https://github.com/poblabs/weewx-belchertown

Eric

Doug Jenkins

unread,
Mar 27, 2022, 9:59:46 PM3/27/22
to weewx...@googlegroups.com
Yes, that is the project. submit an issue and I can see what I can do with a update. It will still be up to the maintainer (Pat O'Brien) to merge it for distribution.

Reply all
Reply to author
Forward
0 new messages