ljmerza / travel-time-card

show travel times for you travel time sensors
MIT License
28 stars 2 forks source link

Fix a bug with Google travel time display if travel time is >= 1 hour #24

Closed Kami closed 2 years ago

Kami commented 3 years ago

This pull request fixes a bug which would incorrectly display travel time as "1 minute" in case the actual travel time as reported by the sensor was >= 1 hour.

Before:

Screenshot from 2021-01-10 14-13-50

After:

Screenshot from 2021-01-10 14-17-17

Background, Context

Travel time sensor for Google API will report travel time duration in the following format in case the travel time is >= 1 hour: X hour YZ mins.

Here is an example:

Screenshot from 2021-01-10 14-18-46

The card code didn't correctly handle this scenario so it parsed "X YZ" string to integer which returns 1.

This pull request fixes that.