Leap Seconds
__all__ = ['logger', 'LeapSeconds', 'gps2utc', 'utc2gps']
module-attribute
Copyright 2020 The Aerospace Corporation
LeapSeconds
Determine the number of leap seconds.
The purpose of this class is to provide a place to store leap second information. It has two methods: one to get the number of leap seconds at a given time and one to get the next leap second.
Source code in gps_time/leapseconds.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
get_leap_seconds(time)
classmethod
Get the current number of leap seconds.
Parameters
time : GPSTime The time at which to find the number of leap seconds
Returns
int The number of leap seconds at time
Source code in gps_time/leapseconds.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
get_next_leap_second(time)
classmethod
Get the next leap second.
This method is used to compute the next leap second from the given time. If the time is after the most recent leap second update and there is no planned future leap second, this will return a None indicating no planned update.
Parameters
time : GPSTime The time for which the next leap second is desired
Returns
Optional[Tuple[GPSTime, int]] A tuple containing the GPSTime of the next leap second and the number of leap seconds at that time. If the next leap second from the desired time is not known, than None is returned.
Source code in gps_time/leapseconds.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
gps2utc(gps_time)
Convert GPS Time to UTC Time
This function adjust the GPS Time using the number of leap seconds to get the UTC time.
Parameters
gps_time : Union[GPSTime, datetime.datetime] The current GPS Time
Returns
datetime.datetime The UTC Time
Source code in gps_time/leapseconds.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
utc2gps(utc_time)
Convert UTC Time to GPS Time
This function adjust the UTC Time using the number of leap seconds to get the GPS time.
Parameters
utc_time : datetime.datetime The current UTC Time
Returns
GPSTime The GPS Time
Source code in gps_time/leapseconds.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |