public_transport_victoria icon indicating copy to clipboard operation
public_transport_victoria copied to clipboard

times displaying in UTC format

Open rozdog opened this issue 9 months ago • 3 comments

The times for the upcoming trains are incorrectly showing. I'm pretty sure the time is displaying in UTC format rather than AEST.

rozdog avatar Nov 13 '23 02:11 rozdog

I'm seeing the same issue. Attributes show the below. It looks like the attributes know the times are in UTC, but it's converting to local.

Attribute Value
Scheduled departure utc 23 November 2023 at 13:33:00
Estimated departure utc Unknown
At platform false
Platform number 1
Flags
Departure sequence 0
Departure 02:33 AM

ajobbins avatar Nov 23 '23 02:11 ajobbins

I've fixed this for myself. I'm running HA in a docker container, but while I had a timezone set in HA, the container was running on UTC. I fixed this by setting a timezone for the container with the environment variable TZ=Australia/Melbourne. Now the sensor is displaying local time.

I'm not a developer and I don't know python, but it looks to me the function on lines 151-155 of 'public_transport_victoria.py' is using a function that must invoke the containers timezone not HAs.

def convert_utc_to_local(utc):
    d = datetime.datetime.strptime(utc, '%Y-%m-%dT%H:%M:%SZ')
    d = d.replace(tzinfo=datetime.timezone.utc)
    d = d.astimezone()
    return d.strftime('%I:%M %p')

ajobbins avatar Nov 28 '23 12:11 ajobbins

thanks for the response. I ended up fixing it as well.

I was also running HA on docker, and decided to migrate to a virtual machine (for a number of reasons) which instantly fixed the issue. Seems like it is largely a bug with docker HA installs.

rozdog avatar Nov 28 '23 21:11 rozdog