MartijnBraam / gpsd-py3

Python 3 GPSD client
105 stars 45 forks source link

fix bug with get_time returning naive timezone instead of utc #34

Open hatsunearu opened 1 year ago

hatsunearu commented 1 year ago

assuming local_time is False: datetime.datetime.strptime(self.time, gpsTimeFormat) will parse the time format string, which is in UTC, and return a datetime object with no timezone info. This naive object will assume that this datetime object was in the local timezone, which is an incorrect assumption--it is in UTC. Properly adding the tzinfo attribute should prevent the datetime object from being wrong in the local_time = False case.