nebius/SWE-bench-extra huggingface dataset:
Repository: unt-libraries/edtf-validate

Issue:
Add '+' or '-' to zoneOffset var to indicate timezone being ahead or behind UTC.

Comments:

Patch:
diff --git a/edtf_validate/valid_edtf.py b/edtf_validate/valid_edtf.py
index 6648d02..53dd491 100644
--- a/edtf_validate/valid_edtf.py
+++ b/edtf_validate/valid_edtf.py
@@ -55,11 +55,11 @@ day = oneThru31
 non_negative_date = non_negative_yearMonthDay | non_negative_yearMonth | non_negative_year
 baseTime = hour + ":" + minute + ":" + second | "24:00:00"
 zoneOffsetHour = oneThru13
-zoneOffset = "Z" | (
-    oneOf("+ -") + zoneOffsetHour + Optional(":" + minute)
+zoneOffset = "Z" | (oneOf("+ -") + (
+    zoneOffsetHour + Optional(":" + minute)
     | "14:00"
     | "00:" + oneThru59
-)
+))
 time = baseTime + Optional(zoneOffset)
 dateAndTime = non_negative_date + "T" + time
 L0Interval = non_negative_date + "/" + non_negative_date


Test patch:
diff --git a/tests/test_valid_edtf.py b/tests/test_valid_edtf.py
index a9b4d84..b74d118 100644
--- a/tests/test_valid_edtf.py
+++ b/tests/test_valid_edtf.py
@@ -122,7 +122,7 @@ Level0 = list(chain([
     '1985-04-12T23:20:30Z',
     '1985-04-12T23:20:30-04',
     '1985-04-12T23:20:30+04:30',
-    pytest.param('2004-01-01T10:10:10+00:59', marks=pytest.mark.xfail),
+    '2004-01-01T10:10:10+00:59',
 ], L0_Intervals))
 
 Level1 = list(chain([
@@ -284,7 +284,7 @@ invalid_edtf_datetimes = [
     '2004-01-01T10:10:40Z00:60',
     '2004-01-01T10:10:10-05:60',
     '2004-01-01T10:10:10+02:00:30',
-    pytest.param('2004-01-01T10:10:1000:59', marks=pytest.mark.xfail),
+    '2004-01-01T10:10:1000:59',
     '-1985-04-12T23:20:30+24',
     '-1985-04-12T23:20:30Z12:00',
 ]
Repository: unt-libraries/edtf-validate

Issue:
Handle `ValueError` in `is_valid_interval`
If you call `is_valid_interval` with a string that contains a date with a time component,  you get a `ValueError` such as in:
```
>>> is_valid_interval('1985-04-12T23:20:30/1990-02-10T23:12:30')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "edtf-validate/edtf_validate/valid_edtf.py", line 468, in is_valid_interval
    from_date = datetime.datetime.strptime(parts[0], "%Y-%m-%d")
  File "python3.7/_strptime.py", line 577, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/opt/lib/python3.7/_strptime.py", line 362, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: T23:20:30
```

We should catch this type of error both in converting the "to" and "from" date and return that it is an invalid interval.

Comments:

Patch:
diff --git a/edtf_validate/valid_edtf.py b/edtf_validate/valid_edtf.py
index 53dd491..e7f73d5 100644
--- a/edtf_validate/valid_edtf.py
+++ b/edtf_validate/valid_edtf.py
@@ -465,9 +465,15 @@ def is_valid_interval(edtf_candidate):
             return zero_year_special_case(parts[0], parts[1], start, end)
         # 2 '-' characters means we are matching year-month-day
         if parts[0].count("-") == 2:
-            from_date = datetime.datetime.strptime(parts[0], "%Y-%m-%d")
+            try:
+                from_date = datetime.datetime.strptime(parts[0], "%Y-%m-%d")
+            except ValueError:
+                return False
         if parts[1].count("-") == 2:
-            to_date = datetime.datetime.strptime(parts[1], "%Y-%m-%d")
+            try:
+                to_date = datetime.datetime.strptime(parts[1], "%Y-%m-%d")
+            except ValueError:
+                return False
         # handle special case of same year season/season range due to
         # the overlap of the months we are designating for the seasons
         if parts[0].count("-") == 1 and parts[1].count("-") == 1:


Test patch:
diff --git a/tests/test_valid_edtf.py b/tests/test_valid_edtf.py
index b74d118..90876a2 100644
--- a/tests/test_valid_edtf.py
+++ b/tests/test_valid_edtf.py
@@ -272,6 +272,9 @@ invalid_edtf_intervals = [
     'Y-61000/-2000',
     '2004-06-11%/2004-%06',
     '2004-06-11%/2004-06~',
+    '2005-07-25T10:10:10Z/2006-01-01T10:10:10Z',
+    '2005-07-25T10:10:10Z/2006-01',
+    '2005-07-25/2006-01-01T10:10:10Z',
 ]
 
 invalid_edtf_datetimes = [