Get time offset from steam server time via WebAPI

    :return: time offset (``None`` when Steam WebAPI fails to respond)
    :rtype: :class:`int`, :class:`None`
760214
def get_time_offset():
    
    try:
        resp = webapi.post('ITwoFactorService', 'QueryTime', 1, params={'http_timeout': 10})
    except:
        return None

    ts = int(time())
    return int(resp.get('response', {}).get('server_time', ts)) - ts
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")
646821
def get_current_time(self):
        
        hms = [int(self.get_current_controller_value(i)) for i in range(406, 409)]
        return datetime.time(*hms)
227614
def timeit(metric, func, *args, **kwargs):
    
    return _client.timeit(metric, func, *args, **kwargs)
332881
def with_time(self):
        
        self.header["X-Authorization-Timestamp"] = str(int(time.time()))
        self.header["Date"] = str(int(time.time()))
        return self
602069
def get_nonce_timestamp(nonce):
    '''
    
    '''
    components = nonce.split(':',2)
    if not len(components) == 3:
        return None

    try:
        return float(components[0])
    except ValueError:
        return None
1132450
def datetime_to_http_date(the_datetime):
    
    timeval = calendar.timegm(the_datetime.utctimetuple())
    return formatdate(timeval=timeval,
                      localtime=False,
                      usegmt=True)
205745
def offset_to_timezone(offset, now=None):
    
    now = now or datetime.now()

    # JS offsets are flipped, so unflip.
    user_offset = -offset

    # Helper: timezone offset in minutes
    def get_tz_offset(tz):
        try:
            return tz.utcoffset(now).total_seconds() / 60
        except (pytz.NonExistentTimeError, pytz.AmbiguousTimeError):
            return tz.localize(now, is_dst=False).utcoffset().total_seconds() / 60

    # Return the timezone with the minimum difference to the user's offset.
    return min(
        (pytz.timezone(tz_name) for tz_name in get_prioritized_timezones()),
        key=lambda tz: abs(get_tz_offset(tz) - user_offset),
    )
529564
function offset(date) {
        // Difference to Greenwich time (GMT) in hours
        var os = Math.abs(date.getTimezoneOffset());
        var h = String(Math.floor(os/60));
        var m = String(os%60);
        h.length === 1? h = '0'+h:1;
        m.length === 1? m = '0'+m:1;
        return date.getTimezoneOffset() < 0 ? '+'+h+m : '-'+h+m;
    }
1089114
def time(host=None, port=None, db=None, password=None):
    '''
    
    '''
    server = _connect(host, port, db, password)
    return server.time()[0]
966818
def get_time():
    """"""

    time_request = '\x1b' + 47 * '\0'
    now = struct.unpack("!12I", ntp_service.request(time_request, timeout=5.0).data.read())[10]
    return time.ctime(now - EPOCH_START)
1332029
def pkt2uptime(pkt, HZ=100):
    """"""
    if not isinstance(pkt, Packet):
        raise TypeError("Not a TCP packet")
    if isinstance(pkt, NoPayload):
        raise TypeError("Not a TCP packet")
    if not isinstance(pkt, TCP):
        return pkt2uptime(pkt.payload)
    for opt in pkt.options:
        if opt[0] == "Timestamp":
            # t = pkt.time - opt[1][0] * 1.0/HZ
            # return time.ctime(t)
            t = opt[1][0] / HZ
            return t
    raise TypeError("No timestamp option")
1037226
def paypal_time(time_obj=None):
    """"""
    warn_untested()
    if time_obj is None:
        time_obj = time.gmtime()
    return time.strftime(PayPalNVP.TIMESTAMP_FORMAT, time_obj)
1247745
def get_packet_time(self, pkt):
        """"""
        if pkt.sent_time:
          t = pkt.sent_time
          sec = int(t)
        else:
          t = pkt.time
          sec = int(t)
        usec = int(round((t-sec)*1000000))
        return (sec,usec)
555265
def get_time_server():
    '''
    
    '''
    ret = salt.utils.mac_utils.execute_return_result(
        'systemsetup -getnetworktimeserver')
    return salt.utils.mac_utils.parse_return(ret)
32462
def get_time(self, **params):
        """"""
        response = self._get('v2', 'time', params=params)
        return self._make_api_object(response, APIObject)
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