Skip to content

Commit

Permalink
revert Time Date Field to previous version
Browse files Browse the repository at this point in the history
  • Loading branch information
HanxSmile committed Apr 6, 2023
1 parent 50d9303 commit a2b4e26
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions dsdl/fields/special.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .base_field import BaseField, BaseFieldWithDomain
from datetime import date, time
from datetime import date, time, datetime
from dsdl.geometry import LABEL


Expand Down Expand Up @@ -511,7 +511,23 @@ class Date(BaseField):
"format": "date"
}

geometry_class = date.fromisoformat
default_args = {"fmt": ""}

args_schema = {
"type": "object",
"properties": {
"fmt": {"type": "string"}
},
"minProperties": 1,
"maxProperties": 1,
"required": ["fmt"]
}

def load_value(self, value):
if self.kwargs["fmt"]:
return datetime.strptime(value, format=self.kwargs["fmt"]).date()
else:
return date.fromisoformat(value)


class Time(BaseField):
Expand All @@ -538,4 +554,20 @@ class Time(BaseField):
"format": "time"
}

geometry_class = time.fromisoformat
default_args = {"fmt": ""}

args_schema = {
"type": "object",
"properties": {
"fmt": {"type": "string"}
},
"minProperties": 1,
"maxProperties": 1,
"required": ["fmt"]
}

def load_value(self, value):
if self.kwargs["fmt"]:
return datetime.strptime(value, format=self.kwargs["fmt"]).time()
else:
return date.fromisoformat(value)

0 comments on commit a2b4e26

Please sign in to comment.