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

timeUntil a timestamp in the future says '... ago' #3

Open
lesiki opened this issue Apr 29, 2014 · 1 comment
Open

timeUntil a timestamp in the future says '... ago' #3

lesiki opened this issue Apr 29, 2014 · 1 comment

Comments

@lesiki
Copy link

lesiki commented Apr 29, 2014

Hi there,

This may just be poor understanding on my behalf, but it looks to me like the timeUntil function handles things a bit strangely: a timestamp 1 day in the future gives "one day ago", and a timestamp one day in the past gives "a day from now". My intuitive understanding would expect these the other way round.

This is shown in the example from the readme:

String hours = time.timeUntil(current - (6 * 60 * 60 * 1000));  // returns "6 hours from now"

Surely you'd expect "6 hours from now" when you provide a time that is 6 hours in the future, not the past?

If I'm correct, I think the fix would be to check for distanceInMilis being positive instead of negative on this line.

@chadkouse
Copy link

I think you're right. A workaround for now is:
time.timeUntil(System.currentTimeMillis() - (yourFutureTime - System.currentTimeMillis()));

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

No branches or pull requests

2 participants