gps_time_to_utc

pyhelpers.ops.gps_time_to_utc(gps_time, as_datetime=True, utc_tai_offset=None)[source]

Converts GPS time to UTC time.

Parameters:
  • gps_time (float) – Standard GPS time in seconds since GPS epoch (6 January 1980).

  • as_datetime (bool) – If True, the function returns the UTC time as datetime type; otherwise string type; defaults to True.

  • utc_tai_offset (float | int | None) – The difference between UTC (Coordinated Universal Time) and the TAI (International Atomic Time), i.e. UTC - TAI; defaults to None.

Returns:

UTC datetime corresponding to the GPS time.

Return type:

datetime.datetime | str

Examples:

>>> from pyhelpers.ops import gps_time_to_utc
>>> gps_time = 1271398985.7822514
>>> utc_time = gps_time_to_utc(gps_time)
>>> utc_time
datetime.datetime(2020, 4, 20, 6, 22, 47, 782251)
>>> utc_time = gps_time_to_utc(gps_time, as_datetime=False)
>>> utc_time
>>> '2020-04-20T06:22:47.782251'