Retrieves timestamps from the import directory, if available.

    Args:
      pefile_object (pefile.PE): pefile object.

    Returns:
      list[int]: import timestamps.
342348
def _GetImportTimestamps(self, pefile_object):
    
    import_timestamps = []
    if not hasattr(pefile_object, 'DIRECTORY_ENTRY_IMPORT'):
      return import_timestamps
    for importdata in pefile_object.DIRECTORY_ENTRY_IMPORT:
      dll_name = getattr(importdata, 'dll', '')
      try:
        dll_name = dll_name.decode('ascii')
      except UnicodeDecodeError:
        dll_name = dll_name.decode('ascii', errors='replace')
      if not dll_name:
        dll_name = '<NO DLL NAME>'

      timestamp = getattr(importdata.struct, 'TimeDateStamp', 0)
      if timestamp:
        import_timestamps.append([dll_name, timestamp])
    return import_timestamps
863581
def timestamps_from_file_list(file_list):
        ""
        timestamps = np.array([Kinect.timestamp_from_filename(fname) for fname in file_list])

        # Handle overflow
        diff = np.diff(timestamps)
        idxs = np.flatnonzero(diff < 0)
        ITEM_SIZE = 2**32
        for i in idxs:
            timestamps[i+1:] += ITEM_SIZE

        return timestamps.flatten()
573982
def read_lsm_timestamps(fh):
    """"""
    size, count = struct.unpack('<ii', fh.read(8))
    if size != (8 + 8 * count):
        log.warning('read_lsm_timestamps: invalid LSM TimeStamps block')
        return []
    # return struct.unpack('<%dd' % count, fh.read(8*count))
    return fh.read_array('<f8', count=count)
790321
def curve_timestamp(self, curve_timestamp):
        
        if curve_timestamp is not None:
            curve_timestamp = str(curve_timestamp)
            if isinstance(curve_timestamp, str):
                curve_timestamp = parse(curve_timestamp).replace(tzinfo=pytz.utc)
            if type(curve_timestamp) == date:
                curve_timestamp = datetime.combine(curve_timestamp, datetime.min.time()).replace(tzinfo=pytz.utc)
            if not curve_timestamp.tzinfo:
                raise ValueError('Cannot set a curve without a timezone')            
            if curve_timestamp > datetime.utcnow().replace(tzinfo=pytz.utc):
                raise ValueError('Cannot set a curve in the future: %s' % curve_timestamp.isoformat())
            self._curve_timestamp = curve_timestamp
660165
def remote_list(timestamps=True):
    
    r = get_remote_file(DICTS_URL)
    lst = []
    for f in r.text.split('\n'):
        if not f:
            continue
        name, date = f.split(':')
        name = name.replace('.txt', '')
        lst.append((name, int(date)) if timestamps else name)

    return lst
1277772
def GetPathInfo(self, timestamp=None):
    
    path_info_timestamp = self._LastEntryTimestamp(self._path_infos, timestamp)
    try:
      result = self._path_infos[path_info_timestamp].Copy()
    except KeyError:
      result = rdf_objects.PathInfo(
          path_type=self._path_type, components=self._components)

    stat_entry_timestamp = self._LastEntryTimestamp(self._stat_entries,
                                                    timestamp)
    result.last_stat_entry_timestamp = stat_entry_timestamp
    result.stat_entry = self._stat_entries.get(stat_entry_timestamp)

    hash_entry_timestamp = self._LastEntryTimestamp(self._hash_entries,
                                                    timestamp)
    result.last_hash_entry_timestamp = hash_entry_timestamp
    result.hash_entry = self._hash_entries.get(hash_entry_timestamp)

    return result
507246
def _dfromtimestamp(timestamp):
    
    try:
        return datetime.date.fromtimestamp(timestamp)
    except OSError:
        timestamp -= time.timezone
        d = datetime.date(1970, 1, 1) + datetime.timedelta(seconds=timestamp)
        if _isdst(d):
            timestamp += 3600
            d = datetime.date(1970, 1, 1) + datetime.timedelta(seconds=timestamp)
        return d
1039649
def _GetDateTime(self, filetime):
    
    if filetime == 0:
      return dfdatetime_semantic_time.SemanticTime('Not set')

    return dfdatetime_filetime.Filetime(timestamp=filetime)
405524
def access_time(self):
    """"""
    timestamp = self._fsntfs_file_entry.get_access_time_as_integer()
    return dfdatetime_filetime.Filetime(timestamp=timestamp)
1290035
def human_timestamp(__timestamp: datetime.datetime) -> str:
    
    numstr = '. a two three four five six seven eight nine ten'.split()

    matches = [
        60 * 60 * 24 * 365,
        60 * 60 * 24 * 28,
        60 * 60 * 24 * 7,
        60 * 60 * 24,
        60 * 60,
        60,
        1,
    ]
    match_names = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second']

    if __timestamp.tzinfo is None:
        __timestamp = __timestamp.replace(tzinfo=datetime.timezone.utc)

    now = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)

    delta = int((now - __timestamp).total_seconds())
    for scale in matches:
        i = delta // scale
        if i:
            name = match_names[matches.index(scale)]
            break
    else:
        i = 0  # Too small

    if i == 0:
        result = 'right now'
    elif i == 1 and name in ('year', 'month', 'week'):
        result = 'last {}'.format(name)
    elif i == 1 and name == 'day':
        result = 'yesterday'
    elif i == 1 and name == 'hour':
        result = 'about an hour ago'
    else:
        result = 'about {} {}{} ago'.format(i if i > 10 else numstr[i], name,
                                            's' if i > 1 else '')
    return result
113330
def get_dt_list(fn_list):
    
    dt_list = np.array([fn_getdatetime(fn) for fn in fn_list])
    return dt_list
687409
def timestamps(self):
        ''''''
        timestamps = set()
        for series in self.groups.itervalues():
            timestamps |= set(series.timestamps)
        return sorted(list(timestamps))
950736
def timesince(self, now=None):
        
        from django.utils.timesince import timesince as timesince_
        return timesince_(self.timestamp, now)
789355
def timestamp_pb(self):
        
        inst = self if self.tzinfo is not None else self.replace(tzinfo=pytz.UTC)
        delta = inst - _UTC_EPOCH
        seconds = int(delta.total_seconds())
        nanos = self._nanosecond or self.microsecond * 1000
        return timestamp_pb2.Timestamp(seconds=seconds, nanos=nanos)
386682
def timestamp(args):
    
    p = OptionParser(timestamp.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    path, = args
    for root, dirs, files in os.walk(path):
        for f in files:
            filename = op.join(root, f)
            atime, mtime = get_times(filename)
            print(filename, atime, mtime)
845898
def _GetTimelineStatEntriesRelDB(api_client_id, file_path, with_history=True):
  """"""
  path_type, components = rdf_objects.ParseCategorizedPath(file_path)

  client_id = str(api_client_id)

  try:
    root_path_info = data_store.REL_DB.ReadPathInfo(client_id, path_type,
                                                    components)
  except db.UnknownPathError:
    return

  path_infos = []
  for path_info in itertools.chain(
      [root_path_info],
      data_store.REL_DB.ListDescendentPathInfos(client_id, path_type,
                                                components),
  ):
    # TODO(user): this is to keep the compatibility with current
    # AFF4 implementation. Check if this check is needed.
    if path_info.directory:
      continue

    categorized_path = rdf_objects.ToCategorizedPath(path_info.path_type,
                                                     path_info.components)
    if with_history:
      path_infos.append(path_info)
    else:
      yield categorized_path, path_info.stat_entry, path_info.hash_entry

  if with_history:
    hist_path_infos = data_store.REL_DB.ReadPathInfosHistories(
        client_id, path_type, [tuple(pi.components) for pi in path_infos])
    for path_info in itertools.chain(*hist_path_infos.itervalues()):
      categorized_path = rdf_objects.ToCategorizedPath(path_info.path_type,
                                                       path_info.components)
      yield categorized_path, path_info.stat_entry, path_info.hash_entry
93613
def tai_timestamp():
    """"""
    timestamp = time.time()
    date = datetime.utcfromtimestamp(timestamp)
    if date.year < 1972:
        return timestamp
    offset = 10 + timestamp
    leap_seconds = [
        (1972, 1, 1),
        (1972, 7, 1),
        (1973, 1, 1),
        (1974, 1, 1),
        (1975, 1, 1),
        (1976, 1, 1),
        (1977, 1, 1),
        (1978, 1, 1),
        (1979, 1, 1),
        (1980, 1, 1),
        (1981, 7, 1),
        (1982, 7, 1),
        (1983, 7, 1),
        (1985, 7, 1),
        (1988, 1, 1),
        (1990, 1, 1),
        (1991, 1, 1),
        (1992, 7, 1),
        (1993, 7, 1),
        (1994, 7, 1),
        (1996, 1, 1),
        (1997, 7, 1),
        (1999, 1, 1),
        (2006, 1, 1),
        (2009, 1, 1),
        (2012, 7, 1),
        (2015, 7, 1),
        (2017, 1, 1),
    ]
    for idx, leap_date in enumerate(leap_seconds):
        if leap_date >= (date.year, date.month, date.day):
            return idx - 1 + offset
    return len(leap_seconds) - 1 + offset