The timestamp of the request in ISO8601 YYYYMMDD'T'HHMMSS'Z' format.

        If this is not available in the query parameters or headers, or the
        value is not a valid format for AWS SigV4, an AttributeError exception
        is raised.
322742
def request_timestamp(self):
        
        amz_date = self.query_parameters.get(_x_amz_date)
        if amz_date is not None:
            amz_date = amz_date[0]
        else:
            amz_date = self.headers.get(_x_amz_date)
            if amz_date is None:
                date = self.headers.get(_date)
                if date is None:
                    raise AttributeError("Date was not passed in the request")

                # This isn't really valid -- seems to be a bug in the AWS
                # documentation.
                if _iso8601_timestamp_regex.match(date):
                    amz_date = date # pragma: nocover
                else:
                    # Parse this as an HTTP date and reformulate it.
                    amz_date = (datetime.strptime(date, _http_date_format)
                                .strftime("%Y%m%dT%H%M%SZ"))
        if not _iso8601_timestamp_regex.match(amz_date):
            raise AttributeError("X-Amz-Date parameter is not a valid ISO8601 "
                                 "string: %r" % amz_date)

        return amz_date
917476
def iso_datetime(timestamp=None):
    
    if timestamp is None:
        timestamp = time.time()
    return datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:19]
579784
def QA_util_stamp2datetime(timestamp):
    
    try:
        return datetime.datetime.fromtimestamp(timestamp)
    except Exception as e:
        # it won't work ??
        try:
            return datetime.datetime.fromtimestamp(timestamp / 1000)
        except:
            try:
                return datetime.datetime.fromtimestamp(timestamp / 1000000)
            except:
                return datetime.datetime.fromtimestamp(timestamp / 1000000000)
966409
def parse_hh_mm_ss(self):
        
        split_count = self.raw.count(":")

        if split_count == 2:  # hh:mm:ss
            return datetime.strptime(str(self.raw).strip(), "%H:%M:%S").time()
        elif split_count == 1:  # mm:ss
            return datetime.strptime(str(self.raw).strip(), "%M:%S").time()

        return datetime.strptime(str(self.raw).strip(), "%S").time()
1080227
def loads_with_timestamp(value, salt):
    """"""
    try:
        signing.loads(value, salt=salt, max_age=-999999)
    except signing.SignatureExpired as e:
        age = float(str(e).split('Signature age ')[1].split(' >')[0])
        timestamp = timezone.now() - datetime.timedelta(seconds=age)
        return timestamp, signing.loads(value, salt=salt)
1266714
def iso8601time(time_tuple):
    
    if time_tuple:
        return time.strftime("%Y-%m-%dT%H:%M:%SZ", time_tuple)
    else:
        return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
909659
private byte[] computeSignature(Request request) {
        String timestampAndQuery = request.getTimestamp() + '\n' +
                request.getSortedQueryParameters() + '\n';

        byte[] timestampAndQueryBytes = timestampAndQuery.getBytes(CHARSET_UTF8);
        byte[] bodyHashBytes = getSha256Hash(request.getData());

        return getHmacSha256Signature(appendArrays(timestampAndQueryBytes, bodyHashBytes));
    }
817927
def aws_v4_signature
      date = OpenSSL::HMAC.digest('sha256', 'AWS4' + @secret_key, @timestamp.strftime('%Y%m%d'))
      region = OpenSSL::HMAC.digest('sha256', date, @aws_session.region)
      service = OpenSSL::HMAC.digest('sha256', region, SERVICE_NAME)
      signing_key = OpenSSL::HMAC.digest('sha256', service, 'aws4_request')

      OpenSSL::HMAC.hexdigest('sha256', signing_key, string_to_sign)
    end
1047834
def ISO8601Format(dt):
   
   isoStr = dt.strftime('%Y-%m-%dT%H:%M:%S')
   if dt.microsecond:
      isoStr += ('.%06d' % dt.microsecond).rstrip('0')
   if dt.tzinfo:
      tz = dt.strftime('%z')
   else:
      if time.daylight and time.localtime().tm_isdst:
         utcOffset_minutes = -time.altzone / 60
      else:
         utcOffset_minutes = -time.timezone / 60
      tz = "%+.2d%.2d" % (utcOffset_minutes / 60, (abs(utcOffset_minutes) % 60))
   if tz == '+0000':
      return isoStr + 'Z'
   elif tz:
      return isoStr + tz[:3] + ':' + tz[3:]
   else:
      # Local offset is unknown
      return isoStr + '-00:00'
673568
def rfc2822_format(val):
    
    if isinstance(val, six.string_types):
        return val
    elif isinstance(val, (datetime.datetime, datetime.date)):
        # Convert to a timestamp
        val = time.mktime(val.timetuple())
    if isinstance(val, numbers.Number):
        return email.utils.formatdate(val)
    else:
        # Bail
        return val
1147239
def get_iso_time_str(timestamp: Union[int, float, str, datetime]=None) -> str:
    """"""
    if isinstance(timestamp, (int, float)):
        maya_dt = maya.MayaDT(timestamp)
    elif isinstance(timestamp, str):
        maya_dt = maya.when(timestamp)
    elif timestamp is None:
        maya_dt = maya.now()
    else:
        raise ValueError(f'`{type(timestamp)}` is not supported')
    return maya_dt.iso8601()
430395
def parse_ISO8601(time_gap):
    
    matcher = None

    if time_gap.count("T"):
        units = {
            "H": ("HOURS", isodate.Duration(hours=1)),
            "M": ("MINUTES", isodate.Duration(minutes=1)),
            "S": ("SECONDS", isodate.Duration(seconds=1))
        }
        matcher = re.search("PT(\d+)([HMS])", time_gap)
        if matcher:
            quantity = int(matcher.group(1))
            unit = matcher.group(2)
            return quantity, units.get(unit)
        else:
            raise Exception("Does not match the pattern: {}".format(time_gap))
    else:
        units = {
            "Y": ("YEARS", isodate.Duration(years=1)),
            "M": ("MONTHS", isodate.Duration(months=1)),
            "W": ("WEEKS", isodate.Duration(weeks=1)),
            "D": ("DAYS", isodate.Duration(days=1))
        }
        matcher = re.search("P(\d+)([YMWD])", time_gap)
        if matcher:
            quantity = int(matcher.group(1))
            unit = matcher.group(2)
        else:
            raise Exception("Does not match the pattern: {}".format(time_gap))

    return quantity, units.get(unit)
107145
def strptime(self, value, format):
        

        value = force_str(value)
        if format == ISO_8601:
            try:
                parsed = parse_datetime(value)
                if not settings.USE_TZ:
                        fr_tz = pytz.timezone(settings.TIME_ZONE)
                        parsed = parsed.astimezone(fr_tz).replace(tzinfo=None)
            except:
                raise APIException(
                    "date parsing error: since parameter use the date format ISO 8601 (ex: 2014-11-18T15:56:58Z)")

            if parsed is None:
                raise APIException(
                    "since parameter use the date format ISO 8601 (ex: 2014-11-18T15:56:58Z)")
            return parsed
        return super(IsoDateTimeField, self).strptime(value, format)
613122
static String getFormattedTimestamp() {
        DateFormat df = dateFormatPool.getAndSet(null);
        if (df == null) {
            df = createISODateFormat();
        }
        String timestamp = df.format(new Date());
        dateFormatPool.set(df);
        return timestamp;
    }
204265
def ts_to_str(jwt_dict):
    
    d = ts_to_dt(jwt_dict)
    for k, v in list(d.items()):
        if isinstance(v, datetime.datetime):
            d[k] = v.isoformat().replace('T', ' ')
    return d
672898
@JsonProperty
    public String timestamp() {
        if (timestampAsText == null) {
            timestampAsText = DateTimeFormatter.ISO_INSTANT.format(timestamp);
        }
        return timestampAsText;
    }
314394
def rfc2822_datetime(s):
    
    date_tuple = parsedate(s)
    if date_tuple is None:
        return None
    return datetime.datetime(*date_tuple[:6]).replace(tzinfo=pytz.utc)