Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

times displaying in UTC format #20

Open
rozdog opened this issue Nov 13, 2023 · 3 comments
Open

times displaying in UTC format #20

rozdog opened this issue Nov 13, 2023 · 3 comments

Comments

@rozdog
Copy link

rozdog commented Nov 13, 2023

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

@ajobbins
Copy link

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
Copy link

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')

@rozdog
Copy link
Author

rozdog commented Nov 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants