question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

deserialize UTC datetime string to EDate

See original GitHub issue

hello aranega,

I’m not sure of the property way to use pyecore to deserialize datetime values from an XMI resource. I constructed an XMI resource using an ecore metamodel and set an attribute to datetime.utcnow(). the resource serialized without issue using resource.save() but upon loading the resource using create_resource I get the following error:

>>> resource = rset.get_resource(URI(inFilePath))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/env/lib/python3.5/site-packages/pyecore/resources/resource.py", line 82, in get_resource
    resource.load(options=options)
  File "/env/lib/python3.5/site-packages/pyecore/resources/xmi.py", line 46, in load
    modelroot = self._init_modelroot(root)
  File "/env/lib/python3.5/site-packages/pyecore/resources/xmi.py", line 113, in _init_modelroot
    self._decode_eattribute_value(modelroot, feature, value)
  File "/env/lib/python3.5/site-packages/pyecore/resources/xmi.py", line 128, in _decode_eattribute_value
    eobject.__setattr__(eattribute.name, val)
  File "/env/lib/python3.5/site-packages/pyecore/ecore.py", line 582, in __set__
    instance_dict[name]._set(value)
  File "/env/lib/python3.5/site-packages/pyecore/valuecontainer.py", line 73, in _set
    self.check(value)
  File "/env/lib/python3.5/site-packages/pyecore/valuecontainer.py", line 46, in check
    raise BadValueError(value, self.feature.eType)
pyecore.valuecontainer.BadValueError: Expected type <pyecore.ecore.EProxy object at 0x10d5c0048>, but got type str with value 2018-06-05 16:15:47.290839 instead

myMetamodel.ecore

...
<eStructuralFeatures xsi:type="ecore:EAttribute" 
    name="documentRevisionDate" 
    eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
...

mySerializeData.xmi

... 
documentRevisionDate="2018-06-05 16:15:47.290839"
...

It also failed to deserialize using a timestamp and timestamp string. please help me understand the property way to serialize/deserialze datetime values.

Thanks for this amazing project,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
TerryKingstoncommented, Jun 11, 2018

aranega,

ran pip install pyecore -U and now UTC date strings are deserializing correctly.

Thanks!

0reactions
aranegacommented, Jun 11, 2018

I’m glad it works well for you 😃. Thanks again for the report!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[QUESTION] How to Deserialize a UTC DateTime String using ...
I have a datetime string I need to deserialize: this is my string with utc ... Parse date string: Best way to parse...
Read more >
How do I get Newtonsoft to deserialize a date as it is and call it ...
You said your desired output is to have DateTimeKind.Utc - but it seems you meant after your conversion to local time?
Read more >
UTC Date is being deserialized to server local time when PUT ...
When I sending data in a HTTP Request with POST method, any date string formatted like "2016-02-05T15:00:00.000Z" is deserialized correctly as ...
Read more >
Deserializing optional date times with Serde - Chris McGrath
The chrono crate handles date times with the DateTime<Utc> type. As the date time value might not be present in the response the...
Read more >
Unable to Extract correct date time from Json using ...
I am able to extract all fields using Deserialize activity However, while extracting the Eventdatetime its capturing some wrong date time ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found