java-timeago icon indicating copy to clipboard operation
java-timeago copied to clipboard

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

Open lesiki opened this issue 11 years ago • 1 comments

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.

lesiki avatar Apr 29 '14 13:04 lesiki

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

chadkouse avatar Oct 18 '14 22:10 chadkouse