-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
I tried creating a "basic" datetime object to serialize and deserialize in omf v1.0.1 (see example below). The object is written to disk without issue however upon deserialization I get a ValueError (ValueError: time data '1-01-01T00:00:00Z' does not match format '%Y-%m-%dT%H:%M:%SZ')
Looking at the technical details here it looks like in some cases only years > 1000 should / could be accepted. I agree the %Y should be zero padding according to the docs but it doesn't look like it. This does look like a datetime bug? but maybe omf could / should be handling this?
eg. This does not work but probably should?
value = datetime.strftime(datetime(1,1,1), '%Y-%m-%dT%H:%M:%SZ')
datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')My question are:
- Should this be somehow caught in validation steps and not allowed?
- Should / could the 0 padding be better enforced? (eg. something like:
value = '000' + valueinDateTime.to_json
import datetime as dt
import omf
pts = omf.PointSetElement(
name=f'Points',
geometry=omf.PointSetGeometry(
vertices=np.array([0,0,0])
),
data=[
omf.DateTimeData(
array=[dt.datetime(1,1,1)],
location='vertices'
),
],
)
proj = omf.Project()
proj.elements = [pts]
omf.OMFWriter(proj, "test.omf")
reader = omf.OMFReader("test.omf")
reader.get_project()OS: Pop-os! (Ubuntu 22.02 derived)
Python: 3.10
omf: 1.0.1
Metadata
Metadata
Assignees
Labels
No labels