Skip to content

Commit

Permalink
KDP-1761: Force t-axis to be timezone aware
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulVanSchayck committed Sep 8, 2023
1 parent 5907c4e commit c8e70a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from datetime import datetime
from datetime import timezone

from covjson_pydantic.coverage import Coverage
from covjson_pydantic.domain import Domain
Expand All @@ -10,7 +11,7 @@
axes={
"x": {"dataType": "float", "values": [1.23]},
"y": {"values": [4.56]},
"t": {"dataType": "datetime", "values": [datetime.datetime.now()]},
"t": {"dataType": "datetime", "values": [datetime.now(tz=timezone.utc)]},
},
),
ranges={"temperature": NdArray(axisNames=["x", "y", "t"], shape=[1, 1, 1], values=[42.0])},
Expand Down
4 changes: 2 additions & 2 deletions src/covjson_pydantic/domain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from datetime import datetime
from enum import Enum
from typing import Generic
from typing import List
Expand All @@ -8,6 +7,7 @@
from typing import TypeVar
from typing import Union

from pydantic import AwareDatetime
from pydantic import ConfigDict
from pydantic import model_validator
from pydantic import PositiveInt
Expand Down Expand Up @@ -61,7 +61,7 @@ class Axes(BaseModel):
x: Optional[Union[ValuesAxis[float], CompactAxis]] = None
y: Optional[Union[ValuesAxis[float], CompactAxis]] = None
z: Optional[Union[ValuesAxis[float], CompactAxis]] = None
t: Optional[ValuesAxis[datetime]] = None
t: Optional[ValuesAxis[AwareDatetime]] = None
composite: Optional[ValuesAxis[Tuple]] = None

@model_validator(mode="after")
Expand Down

0 comments on commit c8e70a3

Please sign in to comment.