Skip to content

Commit 6cbf7bc

Browse files
authored
Merge pull request #300 from snitass/tata-parser-refactor
use dt2ts instead of _parse_time static method
2 parents cd0175c + fef0d63 commit 6cbf7bc

File tree

1 file changed

+3
-8
lines changed
  • circuit_maintenance_parser/parsers

1 file changed

+3
-8
lines changed

circuit_maintenance_parser/parsers/tata.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,15 @@ def parse_html(self, soup: ResultSet) -> List[Dict]:
3535
)
3636
elif prev_lower in ("activity window (gmt)", "revised activity window (gmt)"):
3737
start_end = curr.split("to")
38-
data["start"] = self._parse_time(start_end[0])
39-
data["end"] = self._parse_time(start_end[1])
38+
data["start"] = self.dt2ts(datetime.strptime(start_end[0].strip(), "%Y-%m-%d %H:%M:%S %Z"))
39+
data["end"] = self.dt2ts(datetime.strptime(start_end[1].strip(), "%Y-%m-%d %H:%M:%S %Z"))
4040
elif "extended up to time window" in prev_lower:
4141
if "gmt" in curr.lower():
42-
data["end"] = self._parse_time(curr)
42+
data["end"] = self.dt2ts(datetime.strptime(curr, "%Y-%m-%d %H:%M:%S %Z"))
4343
prev = span.text.strip()
4444

4545
return [data]
4646

47-
@staticmethod
48-
def _parse_time(string: str) -> int:
49-
"""Convert YYYY-MM-DD HH:MM:SS GMT to epoch."""
50-
return int((datetime.strptime(string.strip(), "%Y-%m-%d %H:%M:%S GMT") - datetime(1970, 1, 1)).total_seconds())
51-
5247

5348
class SubjectParserTata(EmailSubjectParser):
5449
"""Custom Parser for Email subject of Tata circuit maintenance notifications."""

0 commit comments

Comments
 (0)