ansemjo / speedtest-plotter

running scheduled speedtests inside docker and plotting the results with gnuplot
MIT License
60 stars 12 forks source link

How to specify local timezone? #10

Closed falconws closed 3 years ago

falconws commented 3 years ago

speedtest-plotter result graph Measurement Date is UTC. I want specify JST (I'm Japanese). How to specify local timezone? TZ environment doesn't work.

ansemjo commented 3 years ago

Hi! Indeed, there currently is no way to specify this. I'm in Germany and still use UTC myself. I don't remember exactly why but I think that the dates that speedtest-cli output in the JSON results were always in UTC.

I like using a TZ environment variable. Is this standard practice otherwise?

falconws commented 3 years ago

@ansemjo https://github.com/ansemjo/speedtest-plotter/blob/master/speedtest-plotter#L60 Is this your code specify UTC?

Is this standard practice otherwise?

I think it's right.

ansemjo commented 3 years ago

@ansemjo https://github.com/ansemjo/speedtest-plotter/blob/master/speedtest-plotter#L60 Is this your code specify UTC?

Yes, here I am using a timestamp in UTC. But that is for compatability with the previous speedtest-cli measurement tool, that always returned UTC timestamps. Furthermore, gnuplot does not seem to easily allow for timezones either but I am looking for workarounds now.

ansemjo commented 3 years ago

I have added a number of commits to add some timezone transformations with dateutil.tz.gettz().

The DockerHub build has just finished, so you can pull the latest image now and start your container with:

docker run -d -p 8000:8000 -e TZ=Asia/Tokyo ansemjo/speedtest

Using -e TZ=JST directly does not seem to work; it needs to be a string from tzselect.

Another sidenote: the timestamps are still explicitly stored as UTC in the database to a) be backwards compatible without any jumps and b) avoid any confusion on daylight savings time.

falconws commented 3 years ago

Thank you very much. I'll try after job.