title: How to get leap seconds from gps epoch for current date in python
body: <p>As I understand for now in python there is no function to get leap seconds from gps epoch for current date. The appropriate patch under investigation/development: <a href="https://bugs.python.org/issue23574" rel="nofollow">leap seconds path in datetime</a></p>
  
  <p>Could you advice the best way how to get leap seconds? I found that solution:</p>
  
  <pre><code>def getLeapSec(Tgps):
    daysFromGPSEpoch = timedelta(seconds=Tgps).days
    tableLeapSec = ([
      [0,  542,  907, 1272, 2003, 2917, 3648, 4013, 4560, 4925, 5290, 5839, 6386, 6935, 9492, 10588, 11865, 12960],
      [0,    1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12,   13,   14,    15,    16,    17]
                   ])
  
    for i in range(1, len(tableLeapSec[0])):
      if daysFromGPSEpoch &lt; tableLeapSec[0][i]:
        return tableLeapSec[1][i-1]
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>In [25]: Tgps = 1092121243.0
  
  In [26]: getLeapSec(Tgps)
  Out[26]: 16
  </code></pre>