File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,8 +79,9 @@ def parse_datetime_to_timestamp(date_str: str) -> Optional[int]:
7979 return None
8080
8181 try :
82- # Try to parse the IOR timestamp format
82+ # Try to parse the IOR timestamp format as local time
8383 dt = datetime .strptime (date_str .strip (), "%a %b %d %H:%M:%S %Y" )
84+ # dt.timestamp() returns local time as Unix timestamp
8485 return int (dt .timestamp ())
8586 except ValueError :
8687 # If parsing fails, return None
Original file line number Diff line number Diff line change @@ -182,9 +182,14 @@ def test_different_months(self):
182182
183183 def test_whitespace_handling (self ):
184184 """Test that function handles whitespace correctly."""
185- assert parse_datetime_to_timestamp (" Sun Jul 27 08:35:34 2025 " ) == 1753630534
186- assert parse_datetime_to_timestamp ("\t Sun Jul 27 08:35:34 2025\t " ) == 1753630534
187- assert parse_datetime_to_timestamp (" Sun Jul 27 08:35:34 2025 " ) == 1753630534
185+ # Compute expected timestamp using local time, so test is robust to environment
186+ from datetime import datetime
187+
188+ base_str = "Sun Jul 27 08:35:34 2025"
189+ expected = int (datetime .strptime (base_str , "%a %b %d %H:%M:%S %Y" ).timestamp ())
190+ assert parse_datetime_to_timestamp (" Sun Jul 27 08:35:34 2025 " ) == expected
191+ assert parse_datetime_to_timestamp ("\t Sun Jul 27 08:35:34 2025\t " ) == expected
192+ assert parse_datetime_to_timestamp (" Sun Jul 27 08:35:34 2025 " ) == expected
188193
189194 def test_invalid_inputs (self ):
190195 """Test that function returns None for invalid inputs."""
You can’t perform that action at this time.
0 commit comments