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))
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)
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]
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))
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))
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))