def get_time_gap_af(s): context_timestamp, dates, instanceID, instanceIDs = s.split('_') context_timestamp = int(context_timestamp) instanceID = int(instanceID) dates = dates.split(':') dates = [int(x) for x in dates] instanceIDs = instanceIDs.split(':') instanceIDs = [int(x) for x in instanceIDs] gaps = [] for d, idx in zip(dates, instanceIDs): if instanceID < idx: this_gap = my_utils.calc_time_gap(d, context_timestamp) gaps.append(this_gap + 1) if len(gaps) == 0: return -1 else: return min(gaps)
def get_clk_cnt_af_sec(s, sec): context_timestamp, dates, instanceID, instanceIDs = s.split('_') context_timestamp = int(context_timestamp) instanceID = int(instanceID) dates = dates.split(':') dates = [int(x) for x in dates] instanceIDs = instanceIDs.split(':') instanceIDs = [int(x) for x in instanceIDs] count = 0 for d, idx in zip(dates, instanceIDs): if instanceID < idx: this_gap = my_utils.calc_time_gap(d, context_timestamp) if (this_gap >= 0) & (this_gap < sec): count += 1 if count == 0: return -1 else: return count