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

Malformed Last Updated field #1490

Closed
luiscoms opened this issue Oct 19, 2022 · 7 comments · Fixed by #1491
Closed

Malformed Last Updated field #1490

luiscoms opened this issue Oct 19, 2022 · 7 comments · Fixed by #1491

Comments

@luiscoms
Copy link
Contributor

Expected Behavior

I set DATE_FORMAT config with following value

DATE_FORMAT = '%Y-%m-%d %H:%M:%S%z'

When I get resource, the _updated field does not show timezone

Actual Behavior

Result of get resource:

Screenshot from 2022-10-19 17-25-11

Fields on MongoDB
Screenshot from 2022-10-19 17-19-50

Environment

  • Python version: 3.9.9
pip freeze -r requirements.txt
config-client==1.1.0
Eve==1.1.5
Eve-Elastic==7.2.1
eve-healthcheck==0.3.1
gunicorn==20.1.0
MarkupSafe==1.1.1
PyQueueManager==1.12.1
PyYAML==6.0
@luiscoms
Copy link
Contributor Author

I've teste with Eve==2.0.2 too, same problem

@nicolaiarocci
Copy link
Member

This is intended behavior, see this for the reasoning around it.

@luiscoms
Copy link
Contributor Author

Ok, but Eve set UTC time here, does not make sense to remove tzinfo

@nicolaiarocci
Copy link
Member

Hmm, that's the oplog push code, and in a conditional branch only executed when the last update info not available. Furthermore, it's set at UTC precisely because all last_updates must be timezone-less (see my link above.)

@luiscoms
Copy link
Contributor Author

luiscoms commented Oct 20, 2022

It was only an example code, here another example.
Why _create field, that is a Date field equals to _updated on MongoDB should be timezone-less?

@luiscoms
Copy link
Contributor Author

A possible fix is

- updates[config.LAST_UPDATED] = datetime.utcnow().replace(microsecond=0)
+ updates[config.LAST_UPDATED] = datetime.utcnow().replace(microsecond=0, tzinfo=timezone.utc)

@nicolaiarocci
Copy link
Member

Feel free to submit a PR, I'll be happy to review it.

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 a pull request may close this issue.

2 participants