tconvert#
- gwpy.time.tconvert(gpsordate: SupportsFloat) datetime[source]#
- gwpy.time.tconvert( ) LIGOTimeGPS
Convert GPS times to ISO-format date-times and vice-versa.
Warning
This method cannot convert exact leap seconds to
datetime.datetime, that object doesn’t support it, so you should consider usingastropy.time.Timedirectly.- Parameters:
- gpsordate
float,astropy.time.Time,datetime.datetime, … Input gps or date to convert, many input types are supported.
- gpsordate
- Returns:
- date
datetime.datetimeorLIGOTimeGPS Converted gps or date.
- date
Notes
If the input object is a
floatorLIGOTimeGPS, it will get converted from GPS format into adatetime.datetime, otherwise the input will be converted intoLIGOTimeGPS.All
datetimeobjects returned by this function are ‘aware’ in the UTC timezone. For more details on timezone handling indatetimeobjects, see Aware and Naive Objects.
Examples
Integers and floats are automatically converted from GPS to
datetime.datetime:>>> from gwpy.time import tconvert >>> tconvert(0) datetime.datetime(1980, 1, 6, 0, 0, tzinfo=datetime.timezone.utc) >>> tconvert(1126259462.3910) datetime.datetime(2015, 9, 14, 9, 50, 45, 391000, tzinfo=datetime.timezone.utc)
while strings are automatically converted to
LIGOTimeGPS:>>> to_gps("Sep 14 2015 09:50:45.391") LIGOTimeGPS(1126259462, 391000000)
Additionally, a few special-case words as supported, which all return
LIGOTimeGPS:>>> tconvert("now") >>> tconvert("today") >>> tconvert("tomorrow") >>> tconvert("yesterday")