reports = local time & PC = UTC

100 views
Skip to first unread message

GCC Observatory

unread,
Mar 20, 2020, 10:33:04 PM3/20/20
to weewx-user
Hello,

Been using weewx for a while now and have always wondered if there's a way to configure it to generate reports that use local time (UTC-5 for me) when the PC clock is set to UTC.  I'm asking because my weewx runs on the same PC as my observatory control software - I'd prefer to set the computer clock to UTC, but the last time I did that, it messed up the weewx reports.  Can anyone tell me if it's possible to "trick" weewx into generating local time reports while keeping the computer clock set to UTC?

Thanks

John Kline

unread,
Mar 20, 2020, 11:09:18 PM3/20/20
to weewx...@googlegroups.com
For Unix/Linux, setting the clock to UTC is the norm and no tricks are needed to get WeeWX to show times in the local time zone.

What OS are you running?  If it is NOT Windows, try running the following command and reply with the output.

timedatectl -a

On Mar 20, 2020, at 7:33 PM, GCC Observatory <gccobse...@gmail.com> wrote:


Hello,

Been using weewx for a while now and have always wondered if there's a way to configure it to generate reports that use local time (UTC-5 for me) when the PC clock is set to UTC.  I'm asking because my weewx runs on the same PC as my observatory control software - I'd prefer to set the computer clock to UTC, but the last time I did that, it messed up the weewx reports.  Can anyone tell me if it's possible to "trick" weewx into generating local time reports while keeping the computer clock set to UTC?

Thanks

--
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/53687f2e-30ed-418a-8ef7-cff65a4353be%40googlegroups.com.

Thomas Keffer

unread,
Mar 21, 2020, 7:46:33 AM3/21/20
to weewx-user
(By "computer clock" I think he means what is in /etc/timezone, that is, the 'local' time.)

Unfortunately, this is not possible with the present architecture of WeeWX. Issue #301 outlines why.

p q

unread,
Mar 21, 2020, 9:04:18 AM3/21/20
to weewx...@googlegroups.com
Have you considered using a virtual machine? You could put weewx on a vm and set the time arbitrarily. 

William Burton

unread,
Mar 24, 2020, 8:53:31 PM3/24/20
to weewx-user
Hello,

Based on your question, I'm assuming the desired timezone you want to run WeeWX under is US/Eastern. If this is incorrect, substitute as appropriate below.

Try this experiment on your shell (assumes bash):
$ date
# displays date in UTC time (default on your machine)
$ TZ=US/Eastern date
# displays date in the US Eastern timezone

This works as it's possible to set and export any environment variable by specifying it on the command line before the command to be executed. The assignment only applies to the following command and would not affect any subsequent commands.

The following solution is completely untested with WeewX so YMMV.

From what I read, it appears possible to define environment variables in a .service file like weewx.service (see the systemd.exec man page):

[Service]
Environment="TZ=US/Eastern"
ExecStart=/home/weewx/bin/weewxd --daemon --pidfile=/var/run/weewx.pid /home/weewx/weewx.conf

WARNING: Don't do this with an existing database unless you have already reprocessed the data appropriately before restarting WeewX. Otherwise, start with a fresh archive database.

Also, since you may need to run the WeeWX utilites from time to time, you should edit your .profile or .bash_profile in your weewx account adding:
export TZ=US/Eastern

Also make sure when you run sudo from the weewx account, that TZ is set correctly. If not, you may have to edit your .bashrc or sudo config in /etc.

In general, you have to be really careful when running any WeeWX commands that the TZ environment variable is set correctly.

Hope this helps,
-Bill
Reply all
Reply to author
Forward
0 new messages