def gps_to_str(gps_time, form=None): """ Convert a LIGOTimeGPS time object into a string. The output format can be given explicitly, but will default as shown in the example. Example: \code >>> gps_to_str(1000000000) 'September 14 2011, 01:46:25 UTC' \endcode @returns a string with the given format. """ if not isinstance(gps_time, LIGOTimeGPS): gps_time = LIGOTimeGPS(float(gps_time)) nano = gps_time.gpsNanoSeconds utc = _datetime.datetime(*_gps_to_utc(int(gps_time))[:6]) utc += _datetime.timedelta(microseconds=nano / 1000.0) if nano and not form: form = "%B %d %Y, %H:%M:%S.%f UTC" elif not form: form = "%B %d %Y, %H:%M:%S UTC" utc_str = utc.strftime(form) return utc_str
def gps_to_str(gps_time, form=None): """ Convert a LIGOTimeGPS time object into a string. The output format can be given explicitly, but will default as shown in the example. Example: \code >>> gps_to_str(1000000000) 'September 14 2011, 01:46:25 UTC' \endcode @returns a string with the given format. """ if not isinstance(gps_time, LIGOTimeGPS): gps_time = LIGOTimeGPS(float(gps_time)) nano = gps_time.gpsNanoSeconds utc = _datetime.datetime(*_gps_to_utc(int(gps_time))[:6]) utc += _datetime.timedelta(microseconds=nano/1000.0) if nano and not form: form = "%B %d %Y, %H:%M:%S.%f UTC" elif not form: form = "%B %d %Y, %H:%M:%S UTC" utc_str = utc.strftime(form) return utc_str
def gps_to_utc(gps_time): """Convert a GPS time into a `datetime.datetime` @returns a Python `datetime.datetime` object in UTC """ return _datetime.datetime(*_gps_to_utc(int(gps_time))[:7]).replace( microsecond=0)
def gps_to_utc(gps_time): """Convert a GPS time into a `datetime.datetime` @returns a Python `datetime.datetime` object in UTC """ return _datetime.datetime(*_gps_to_utc(int(gps_time))[:7])