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

Enhance: Fix current time by RealClock #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jddeep
Copy link
Contributor

@jddeep jddeep commented Apr 9, 2019

Fixes #287

  • Run the unit tests with gradlew app:connectedGmsDebugAndroidTest to make sure you didn't break anything (with an emulator running or phone connected)

  • If you have multiple commits please combine them into one commit by squashing them.

@jddeep
Copy link
Contributor Author

jddeep commented Apr 9, 2019

@jaydeetay Please have a look.

@jddeep
Copy link
Contributor Author

jddeep commented Apr 10, 2019

@jaydeetay @barbeau I have updated it. Please review.

@barbeau
Copy link
Contributor

barbeau commented Apr 10, 2019

@jaydeetay will need to weigh in here as he's more familiar with the code and history of project, but I don't think any change is needed to the code - I'm not sure I understand the TODO comment

@jddeep
Copy link
Contributor Author

jddeep commented Apr 10, 2019

@barbeau Yes even though the TODO comment is not appropriate. I have updated the code for accurate time according to UTC, the user be in any time zone.

@jddeep
Copy link
Contributor Author

jddeep commented Apr 10, 2019

@jaydeetay @barbeau I also think that we could use two methods here, one for returning time in UTC and other for the local time.

// For getting the time in UTC
long offset = currentTime.get(Calendar.ZONE_OFFSET) +
currentTime.get(Calendar.DST_OFFSET);
return currentTime.getTimeInMillis() + offset;
Copy link
Member

Choose a reason for hiding this comment

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

Why are the offsets needed? The API docs say getTimeInMillis already returns UTC. I'm a bit rusty on this stuff. It's not obvious to me why this is better than the existing code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is - the existing code seems right to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well not that it is completely true. I have seen time differences using the SystemClock . The offsets are there for confirmation on the accuracy (if ever there is a time zone issue on any device) . @jaydeetay

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.

3 participants