Пример #1
0
def _timestamp(line: str) -> Timestamp:
    """
    Returns the report timestamp from the first line
    """
    text = line[26:43].strip()
    timestamp = datetime.strptime(text, r"%m/%d/%Y  %H%M")
    return Timestamp(text, timestamp.replace(tzinfo=timezone.utc))
Пример #2
0
def make_timestamp(timestamp: str,
                   time_only: bool = False,
                   target_date: dt.date = None) -> Timestamp:
    """Returns a Timestamp dataclass for a report timestamp in ddhhZ or ddhhmmZ format"""
    if not timestamp:
        return None
    date_obj = parse_date(timestamp, time_only=time_only, target=target_date)
    return Timestamp(timestamp, date_obj)
Пример #3
0
def _find_time_periods(line: List[str], timestamp: datetime) -> List[dict]:
    """Find and create the empty time periods"""
    previous = timestamp.hour
    periods = []
    for hourstr in line:
        if not hourstr:
            continue
        hour = int(hourstr)
        previous, difference = hour, hour - previous
        if difference < 0:
            difference += 24
        timestamp += timedelta(hours=difference)
        periods.append(Timestamp(hourstr, timestamp))
    return [{"time": time} for time in periods]
Пример #4
0
def make_timestamp(timestamp: str) -> Timestamp:
    """
    Returns a Timestamp dataclass for a report timestamp in ddhhZ or ddhhmmZ format
    """
    if timestamp:
        return Timestamp(timestamp, parse_date(timestamp))
Пример #5
0
def make_timestamp(timestamp: str, time_only: bool = False) -> Timestamp:
    """
    Returns a Timestamp dataclass for a report timestamp in ddhhZ or ddhhmmZ format
    """
    if timestamp:
        return Timestamp(timestamp, parse_date(timestamp, time_only=time_only))
Пример #6
0
def _timestamp(line: str) -> Timestamp:
    """Returns the report timestamp from the first line"""
    start = line.find("GUIDANCE") + 11
    text = line[start : start + 16].strip()
    timestamp = datetime.strptime(text, r"%m/%d/%Y  %H%M")
    return Timestamp(text, timestamp.replace(tzinfo=timezone.utc))