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

Replace datetime.now() with datetime.utcnow() to match global users base #555

Closed
1 of 3 tasks
mtreacy002 opened this issue Apr 30, 2020 · 11 comments · Fixed by #556
Closed
1 of 3 tasks

Replace datetime.now() with datetime.utcnow() to match global users base #555

mtreacy002 opened this issue Apr 30, 2020 · 11 comments · Fixed by #556
Assignees
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Type: Enhancement New feature or request.

Comments

@mtreacy002
Copy link
Member

mtreacy002 commented Apr 30, 2020

Description

As a developer,
I need to use datetime.utcnow() for dealing with date/time
so that I can make sure the data on dates is stored correctly according to their timezones.

Mocks

N/A

Acceptance Criteria

  • Change datetime.now() to datetime.utcnow() in all occurrences in the existing code.

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 hours

@isabelcosta
Copy link
Member

Thank is a very good catch 👏 Thank you for reporting it @mtreacy002 . Could you follow the user story template for consistency of issues and for whoever takes on this, is able to understand the user story and definition of done? From what I understand what we can do for future data is to use datetime.utcnow() in every place it uses date, right?

@isabelcosta isabelcosta added Category: Coding Changes to code base or refactored code that doesn't fix a bug. Type: Enhancement New feature or request. labels Apr 30, 2020
@mtreacy002
Copy link
Member Author

So, should I close this issue and use the user story template? I'm currently using the feature request template... 😂 Wasn't sure which one to use, but definitely don't think it's a bug.

@isabelcosta
Copy link
Member

I also don't think it is a bug 😆 But its definitely something that was overlooked and should be fixed?! Its an inconsistency of data issue. No need to close the issue, you can edit it and copy the markdown format of user-story.md inside the .github/ISSUE_TEMPLATE on this repository @mtreacy002

@mtreacy002
Copy link
Member Author

Ok, will do that now 😉

@mtreacy002 mtreacy002 changed the title feat: Replace datetime.now() with datetime.utcnow() to match global users base Replace datetime.now() with datetime.utcnow() to match global users base Apr 30, 2020
@mtreacy002
Copy link
Member Author

@isabelcosta, is this ok now? I'm not sure what to put the title tag as - User story: seems to be too long for the title heading or would that be fine? Also, yes, the future data is to use the datetime.utcnow().

@mtreacy002
Copy link
Member Author

Can I work on this issue tomorrow? I have a plan tonight with the family. If I'm able to finish early with them, I'll try to work on this issue tonight.

@isabelcosta
Copy link
Member

@mtreacy002

is this ok now?

It's perfect :)

Can I work on this issue tomorrow? I have a plan tonight with the family. If I'm able to finish early with them, I'll try to work on this issue tonight.

I will assign this to you. No need to explain you unavailability for today, take your time! I hope you enjoy your time with your family, these are tough times and nothing is more important than to spend time with your loved ones 🤗

@mtreacy002
Copy link
Member Author

mtreacy002 commented Apr 30, 2020

Thanks, @isabelcosta. I have one other question. For registration, we're using time.time() instead of datetime.now(). Do you want me to replace this with datetime.utcnow() too or keep It as it is?

@isabelcosta
Copy link
Member

@mtreacy002 it should be done the same way everyday. Does datetime.utcnow() return a UNIX timestamp or a datetime obj representation?

@mtreacy002
Copy link
Member Author

mtreacy002 commented May 3, 2020

@mtreacy002 it should be done the same way everyday. Does datetime.utcnow() return a UNIX timestamp or a datetime obj representation?

@isabelcosta. Similar to datetime.now() we've use in our existing code, the datetime.utcnow() also returns a datetime obj representation. But I can see in our code that we're using .timestamp() to change it to UNIX form. I think the reason we're using time.time() for registration is more for the 30 days cron job on automatic delete if email didn't get verified. So, I think in this sense it's ok to leave it as it is.
Although, I think we should be able to achieve the same if we use the datetime.utcnow().timestamp() on register. Although, time.time() is considered to be better to deal with time since it prevents dst ambiguity and not as limited in its support to timezone as datetime. What's your thoughts on this?

@mtreacy002
Copy link
Member Author

mtreacy002 commented May 3, 2020

Also, I'm still learning about this date and time concepts. But I noticed that we're currently using the naive objects of the datetime (regardless of .now() or .utcnow()). The suggestions I've read so far (e.g. one example here) incline towards using the timezone aware (offset-aware) object?
My gut feelings says it might be good to keep the offset-naive in the database for consistency and only convert it to an offset-aware by considering the location of user who sends the request at run time. This will need some UI change as well as backend refactoring coz we need user to give information on their Timezone. Maybe this can be for future improvement.
Again, I'm a newbie so I'm interested to see how this evolve.... 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Type: Enhancement New feature or request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants