Skip to content

Commit d163969

Browse files
Generate git
1 parent e731cb6 commit d163969

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

services/git/src/stackit/git/models/instance.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import json
1818
import pprint
19+
import re # noqa: F401
1920
from datetime import datetime
2021
from typing import Any, ClassVar, Dict, List, Optional, Set
2122

@@ -61,6 +62,19 @@ class Instance(BaseModel):
6162
"version",
6263
]
6364

65+
@field_validator("created", mode="before")
66+
def created_change_year_zero_to_one(cls, value):
67+
"""Workaround which prevents year 0 issue"""
68+
if isinstance(value, str):
69+
# Check for year "0000" at the beginning of the string
70+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
71+
if value.startswith("0000-01-01T") and re.match(
72+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
73+
):
74+
# Workaround: Replace "0000" with "0001"
75+
return "0001" + value[4:] # Take "0001" and append the rest of the string
76+
return value
77+
6478
@field_validator("state")
6579
def state_validate_enum(cls, value):
6680
"""Validates the enum"""

0 commit comments

Comments
 (0)