Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arrow/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ class TzinfoParser:
"""

_TZINFO_RE: ClassVar[Pattern[str]] = re.compile(
r"^(?:\(UTC)*([\+\-])?(\d{2})(?:\:?(\d{2}))?"
r"^(?:\(UTC)*([\+\-])?(\d{2})(?:\:?(\d{2}))?(?![0-9.:])"
)

@classmethod
Expand Down
12 changes: 12 additions & 0 deletions test_arrow_get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import arrow
try:
a = arrow.get("+03:00.34")
print(f"Parsed '+03:00.34' as: {a}")
except Exception as e:
print(f"Failed to parse '+03:00.34': {e}")

try:
a = arrow.get("2023-10-10T10:00:00+03:00.34")
print(f"Parsed '2023-10-10T10:00:00+03:00.34' as: {a}")
except Exception as e:
print(f"Failed to parse '2023-10-10T10:00:00+03:00.34': {e}")
10 changes: 10 additions & 0 deletions test_reproduce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import arrow
from datetime import datetime

try:
# Passing a string that contains a timezone but isn't a full datetime
# arrow.get('2023-10-10 10:00:00', tzinfo='+03:00.34')
a = arrow.get(datetime(2023, 10, 10), tzinfo='+03:00.34')
print(f"Parsed with tzinfo='+03:00.34' as: {a}")
except Exception as e:
print(f"Failed with tzinfo='+03:00.34': {e}")
8 changes: 8 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,14 @@ def test_parse_utc_withoffset(self):
"(UTC+01:00) Amsterdam, Berlin, Bern, Rom, Stockholm, Wien"
) == timezone(timedelta(seconds=3600))

def test_parse_partial_offset_fail(self):
# Regression tests for issue where partial offsets were matched
with pytest.raises(parser.ParserError):
self.parser.parse("+03:00.34")

with pytest.raises(parser.ParserError):
self.parser.parse("+03005")

def test_parse_iso(self):
assert self.parser.parse("01:00") == timezone(timedelta(seconds=3600))
assert self.parser.parse("11:35") == timezone(
Expand Down
Loading