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

Projects
None yet
3 participants
@mbaechtold
Contributor

mbaechtold commented Aug 26, 2015

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')

This comment has been minimized.

@jone

jone Aug 26, 2015

Member

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 😕

This comment has been minimized.

@mbaechtold

mbaechtold Aug 26, 2015

Contributor

Good idea 👍 I have made the needed modifications.

@maethu

This comment has been minimized.

Member

maethu commented Aug 26, 2015

👍

jone added a commit that referenced this pull request Aug 28, 2015

Merge pull request #18 from collective/add-datetime-deserializer
Implement new deserializer for datetime fields.

@jone jone merged commit 5def5d4 into master Aug 28, 2015

1 check passed

default CI Status: 2 SUCCESS
Details

@jone jone deleted the add-datetime-deserializer branch Aug 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment