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

Implement new deserializer for datetime fields. #18

Merged
merged 1 commit into from Aug 28, 2015

Conversation

mbaechtold
Copy link
Member

No description provided.

def __call__(self, value, filestore, item,
disable_constraints=False, logger=None):
if isinstance(value, basestring):
value = datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example with collective.jsonify, we might have differently formatted dates, e.g. 2004/12/30 00:20:00 GMT+1.

I propose to let zope's DateTime handle everything and to not define a format:

>>> from DateTime import DateTime
>>> DateTime('2015-12-31 17:59:59').asdatetime()
datetime.datetime(2015, 12, 31, 17, 59, 59)
>>> DateTime("2004/12/30 00:20:00 GMT+1").asdatetime()
datetime.datetime(2004, 12, 30, 0, 20, tzinfo=<StaticTzInfo 'GMT+1'>)

alternatively we'd have to make the format configurable 😕

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍 I have made the needed modifications.

@maethu
Copy link
Member

maethu commented Aug 26, 2015

👍

jone added a commit that referenced this pull request Aug 28, 2015
Implement new deserializer for datetime fields.
@jone jone merged commit 5def5d4 into master Aug 28, 2015
@jone jone deleted the add-datetime-deserializer branch August 28, 2015 08:17
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

Successfully merging this pull request may close these issues.

None yet

3 participants