Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeData can't make a round trip? #127

Open
WesleyTheGeolien opened this issue Apr 12, 2023 · 0 comments
Open

DateTimeData can't make a round trip? #127

WesleyTheGeolien opened this issue Apr 12, 2023 · 0 comments

Comments

@WesleyTheGeolien
Copy link

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' + value in DateTime.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant