Get timestamp token - communications layer
@return - byte[] - TSA response, raw bytes (RFC 3161 encoded)
979535
protected byte[] getTSAResponse(byte[] requestBytes) throws Exception {
        // Setup the TSA connection
        URL url = new URL(tsaURL);
        URLConnection tsaConnection;
        tsaConnection = (URLConnection) url.openConnection();
        
        tsaConnection.setDoInput(true);
        tsaConnection.setDoOutput(true);
        tsaConnection.setUseCaches(false);
        tsaConnection.setRequestProperty("Content-Type", "application/timestamp-query");
        //tsaConnection.setRequestProperty("Content-Transfer-Encoding", "base64");
        tsaConnection.setRequestProperty("Content-Transfer-Encoding", "binary");
        
        if ((tsaUsername != null) && !tsaUsername.equals("") ) {
            String userPassword = tsaUsername + ":" + tsaPassword;
            tsaConnection.setRequestProperty("Authorization", "Basic " +  Base64.encodeBytes(userPassword.getBytes()));
        }
        OutputStream out = tsaConnection.getOutputStream();
        out.write(requestBytes);
        out.close();
        
        // Get TSA response as a byte array
        InputStream inp = tsaConnection.getInputStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int bytesRead = 0;
        while ((bytesRead = inp.read(buffer, 0, buffer.length)) >= 0) {
            baos.write(buffer, 0, bytesRead);
        }
        byte[] respBytes = baos.toByteArray();
        
        String encoding = tsaConnection.getContentEncoding();
        if (encoding != null && encoding.equalsIgnoreCase("base64")) {
            respBytes = Base64.decode(new String(respBytes));
        }
        return respBytes;
    }
1319638
def encode(timestamp):
    
    seconds = int(timestamp)
    nanoseconds = int((timestamp - seconds) * 1000000000)
    seconds = seconds + _OFFSET
    encoded = b2a_hex(struct.pack(_STRUCTURE, seconds, nanoseconds))
    return "@" + encoded.decode("ascii")
730651
def Timestamp():
    
    timestamp = ''
    try:
        timestamp = str(datetime.datetime.now())+' UTC'
    except Exception as e:  # pragma: no cover
        logger.error('Could not get current time ' + str(e))
    return timestamp
440833
public String getTimestamp() {
        return (data != null && data.payload != null) ? data.payload.timestamp : null;
    }
658173
private function getSessionTimestamp()
    {
        if ($this->_phpsession && isset($_SESSION[$this->_sessionName]->SessionID))
            $timestamp = $_SESSION[$this->_sessionName]->SessionID;


        if ($this->_cookie && isset($_COOKIE[$this->_sessionName . "_Timestamp"]))
            $timestamp = $_COOKIE[$this->_sessionName . "_Timestamp"];

        return $timestamp;
    }
481667
def get_timestamp(self, **kwargs):
        """"""
        timestamp = kwargs.get('timestamp')
        if not timestamp:
            now = datetime.datetime.utcnow()
            timestamp = now.strftime("%Y-%m-%dT%H:%M:%S") + ".%03d" % (now.microsecond / 1000) + "Z"

        return timestamp
736333
def access_token(self):
        
        access_token = self.session.get(self.access_token_key)
        if access_token:
            if not self.expires_at:
                # user provided access_token, just return it
                return access_token

            timestamp = time.time()
            if self.expires_at - timestamp > 60:
                return access_token

        self.fetch_access_token()
        return self.session.get(self.access_token_key)
158135
public function getJwtToken()
    {
        if ($this->token && $this->token->isValid()) {
            return $this->token;
        }

        $url = $this->options['token_url'];

        $requestOptions = array_merge(
            $this->getDefaultHeaders(),
            $this->auth->getRequestOptions()
        );

        $response = $this->client->request('POST', $url, $requestOptions);
        $body = json_decode($response->getBody(), true);

        $expiresIn = isset($body[$this->options['expire_key']]) ? $body[$this->options['expire_key']] : null;

        if ($expiresIn) {
            $expiration = new \DateTime('now + ' . $expiresIn . ' seconds');
        } elseif (count($jwtParts = explode('.', $body[$this->options['token_key']])) === 3
            && is_array($payload = json_decode(base64_decode($jwtParts[1]), true))
            // https://tools.ietf.org/html/rfc7519.html#section-4.1.4
            && array_key_exists('exp', $payload)
        ) {
            // Manually process the payload part to avoid having to drag in a new library
            $expiration = new \DateTime('@' . $payload['exp']);
        } else {
            $expiration = null;
        }

        $this->token = new JwtToken($body[$this->options['token_key']], $expiration);

        return $this->token;
    }
1005648
private function timestamp() {
    if ($this->config['force_timestamp'] === false) {
      $time = time();
    } else {
      $time = $this->config['force_timestamp'];
    }
    return (string) $time;
  }
1161749
def time(self):
        
        # If the Timestamps have a timezone that is not UTC,
        # convert them into their i8 representation while
        # keeping their timezone and not using UTC
        if self.tz is not None and not timezones.is_utc(self.tz):
            timestamps = self._local_timestamps()
        else:
            timestamps = self.asi8

        return tslib.ints_to_pydatetime(timestamps, box="time")
778300
def get_timestamp_info(value):
    
    value, offset = _split_offset(value)
    fmt, microsec = _get_timestamp_format(value)
    dt_value = _datetime_obj_factory(value, fmt)
    return dt_value, fmt, offset, microsec
77570
public String getRawTimestamp() throws IOException {

        final NetTimeConfiguration config = this.getNetTimeConfiguration();

        String address = config.getTimeServerAddress();
        int port = config.getTimeServerPort();
        int timeout = config.getConnectionTimeout();

        return getDaytimeReply(address, port, timeout);

    }
221992
def get_timestamp_metadata(self):
        
        # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template
        metadata = dict(self._mdata['timestamp'])
        metadata.update({'existing_date_time_values': self._my_map['timestamp']})
        return Metadata(**metadata)
153341
function getToken()
    {
        if (! $this->token )
            $this->token = $this->exchangeToken();
        elseif (\Poirot\OAuth2Client\checkExpiry( $this->token->getDateTimeExpiration() ))
            $this->token = $this->exchangeToken();


        return $this->token;
    }
661701
def _timestamp():
    """"""
    moment = time.time()
    moment_us = repr(moment).split('.')[1]
    return time.strftime("%Y-%m-%d-%H-%M-%S-{}".format(moment_us), time.gmtime(moment))
562081
def getTimestampUTC():
    
    utc     = datetime.datetime.utcnow()
    ts_sec  = calendar.timegm( utc.timetuple() )
    ts_usec = utc.microsecond
    return ts_sec, ts_usec
389600
function timestamp () {
  const date = new Date()

  return [
    zeropad(date.getHours()),
    zeropad(date.getMinutes()),
    zeropad(date.getSeconds())
  ].join(':')
}