Skip to content
Snippets Groups Projects
Commit f5fd155e authored by Maeva Pourpoint's avatar Maeva Pourpoint
Browse files

Clarify that if statement on time_stamp variable is to check that the time...

Clarify that if statement on time_stamp variable is to check that the time stamp and by extension the input file are properly formatted
parent 75a8e759
No related branches found
No related tags found
1 merge request!3Util functions
......@@ -117,6 +117,8 @@ def convert_coordinate(coordinate: str, hemisphere: str) -> Optional[float]:
def convert_time(time_stamp: str) -> Optional[UTCDateTime]:
"""Convert time stamp recorded by LEMI to UTC."""
msg = ("Failed to convert time stamp - {} - to UTC!".format(time_stamp))
# Check that time_stamp is properly formatted - Otherwise this may indicate
# that the input file was corrupted
if re.match(r"^\d{4} \d{2} \d{2} \d{2} \d{2} \d{2}$", time_stamp):
try:
time_stamp = UTCDateTime(time_stamp)
......
......@@ -185,7 +185,7 @@ class TestConvertTime(unittest.TestCase):
def test_convert_time_erroneous_type(self):
"""Test basic functionality of convert_time."""
time_stamp = '2020 09 30 20 74 00a'
time_stamp = '2021 111 222 1 1 1'
self.assertEqual(convert_time(time_stamp), None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment