code: def T(t, step=30):
      
      if hasattr(t, 'timestamp'):
          timestamp = t.timestamp()
      else:
          # python 2
          if t.tzinfo is None:
              timestamp = time.mktime(t.timetuple())
          else:
              utc_naive  = t.replace(tzinfo=None) - t.utcoffset()
              timestamp = (utc_naive - datetime.datetime(1970, 1, 1)).total_seconds()
  
      return int(timestamp) // step
docs: The TOTP T value (number of time steps since the epoch)