gps_time
This file will become your README and also the index of your documentation.
Breaking Change
Prior to version 3.x, gps_time did not include any timezone
information, i.e. all datetimes used by gps_time were “naive”. This
could lead to errors for versions of python that default to “aware”
datetime objects. In version 3, gps_time is updated to function using
aware datetime objects. If you pass gps_time a naive datetime, it will
assume that it is meant to represent UTC time. As this was the expected
behavior, there should be minimal impact, but this may result in errors
to existing code bases.
Install
Installation can be achieved using pip, specifically
pip install gps_time
How to use
This module is relatively straightfoward to use. The
GPSTime
objects are generated (using arbitrary numbers) by
gps_time1 = GPSTime(week_number=1872, time_of_week=3324.654324324234324)
gps_time2 = GPSTime(week_number=1875, time_of_week=9890874.32)
2
Notice that the time of week for gps_time2 is longer than a week. The
GPSTime
object will automatically adjust the week number and time of week to
reasonable values.
print(gps_time2)
Conversion
The
GPSTime
objects can also created from datetime.datetime objects
gps_time3 = GPSTime.from_datetime(datetime.datetime(2017, 9, 2, 13, 23, 12, 211423)) print(gps_time3)
GPSTime
can likewise be converted to datetime.datetime object. However, one
must be careful because datetime.datetime objects only preserve
microsecond resolution. Converting from
GPSTime
to datetime.datetime can lose information. The opposite conversion
does not lose information.
print(f"GPS Time: {gps_time1}")
print(f"Datetime: {gps_time1.to_datetime()}")
print("")
print(f"Lost Precision: {gps_time1 - GPSTime.from_datetime(gps_time1.to_datetime())}")
Operators
GPSTime
has comparison operators defined (equality, less than, etc.). It also
has addition and subtraction defined. In general, one can add/subtract
either floats or other
GPSTimes.
For floats, it is interpreted as a time shift in seconds (forward for
addition, backward for subtraction). This operation accounts for the
time of week. In-place addition and subtraction, i.e. the += and -=
operators are supported for floats.
time_shift_seconds = 23431123.3243
print(f"Addition (float): {gps_time2 + time_shift_seconds}")
print(f"Subtraction (float): {gps_time2 - time_shift_seconds}")
Alternatively, addition and subtraction can be done using two
GPSTime
objects. Subtraction finds the time difference in seconds (as a float).
Addition essentially sums the week numbers and times of week. Notice
that in-place addition and subtraction are not supported for two
GPSTime
objects.
print(f"Addition (GPSTime): {gps_time2 + gps_time1}")
print(f"Subtraction (GPSTime): {gps_time2 - gps_time1}")
License
Copyright (2020) The Aerospace Corporation. All Rights Reserved
The gps_time module releasded under the Apache2 license.
Open Source Licenses
This module is built on the nbdev template, which is used under the
Apache2 license.
Formatting
As much as possible for jupyter notebooks, the black formatting standard will be used. To apply black to jupyter notebooks, the jupyter-black extension can be used.
Release files for gps-time 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gps_time-3.0.0.tar.gz | 23.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gps_time-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.5 kB
Release files / gps_time-3.0.0.tar.gz
| Download URL | gps_time-3.0.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6b1fae52b177da97293e16488c3aaebe37df7e66814afbf3abaadc90af90e30
|
|
BLAKE2b-256 checksum How to use checksums |
8a4e862eb591b89141f4bb930628da2f84d82b5e8d28984c6e46e0337c7ff750
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 17, 2025.
Transparency logRelease files / gps_time-3.0.0-py3-none-any.whl
| Download URL | gps_time-3.0.0-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
004a0870a8b5ea90c8da0b533d58d9cb49b2fc9ce903da55d41f2794e3fc4d67
|
|
BLAKE2b-256 checksum How to use checksums |
d5c7edcdfad933791e4add24533a74f089945173111a1d88ec3e569605e0ef0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 17, 2025.
Transparency log