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

Do not use datetime.datetime.utcnow() #2183

Closed
matrss opened this issue Feb 8, 2024 · 6 comments · Fixed by #2225
Closed

Do not use datetime.datetime.utcnow() #2183

matrss opened this issue Feb 8, 2024 · 6 comments · Fixed by #2225
Assignees
Labels
Milestone

Comments

@matrss
Copy link
Collaborator

matrss commented Feb 8, 2024

There are multiple locations where this function is used. It is documented as being potentially dangerous and should be replaced with datetime.datetime.now(tz=datetime.timezone.utc): https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

This came up in #2177 (comment).

Related to #2122.

@vikas-chaudhary-2802
Copy link

i love to work on this issue, can you please assign me ?

@matrss
Copy link
Collaborator Author

matrss commented Feb 9, 2024

Sure.

@Preetam-Das26
Copy link
Collaborator

Can I work on this issue? @matrss

@matrss
Copy link
Collaborator Author

matrss commented Feb 22, 2024

There are more instances of utcnow() remaining:

$ git grep -n 'utcnow'
mslib/mscolab/models.py:184:    created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
mslib/mscolab/models.py:208:    created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
mslib/msui/wms_control.py:478:            datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0)))
mslib/msui/wms_control.py:480:            datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0)))
mslib/msui/wms_control.py:843:                        end_time = datetime.utcnow()

@matrss matrss reopened this Feb 22, 2024
@ReimarBauer
Copy link
Member

ReimarBauer commented Feb 22, 2024

We have to be carefully not to create a dependency to mscolab in the msui code parts.

@Myrausman
Copy link
Contributor

Hey @ReimarBauer , Can I work on the remaining issue and could you please assign it to me?

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