lightvector / arimaa-server

Arimaa server
Other
9 stars 2 forks source link

Improve displayed timestamps for chat messages #124

Open lightvector opened 8 years ago

lightvector commented 8 years ago

Currently, the time indicator for chat only shows hours, minutes, and seconds. When this wraps around, it's hard to know how long has passed. Also maybe it should use a 24h display instead of a 12h display.

mattj256 commented 8 years ago

What's the desired behavior?

Right now I think the chat window shows all messages since the beginning of time? Are there plans to limit what's shown in the chat screen? Does that relate to this issue? If the chat window only goes back a few hours or until midnight UTC it makes the disambiguation problem easier.

lightvector commented 8 years ago

It goes back some 1000 or 2000 or 5000 messages, I forget exactly how much. We could also implement a time-based limit, but we would still need a numeric limit.

I think switching to a 24hr clock would alone help a lot, which should just be a matter of looking up the docs for datetime related functions in Javascript.

On Sun, Jan 24, 2016 at 10:17 PM, mattj256 notifications@github.com wrote:

What's the desired behavior?

Right now I think the chat window shows all messages since the beginning of time? Are there plans to limit what's shown in the chat screen? Does that relate to this issue? If the chat window only goes back a few hours or until midnight UTC it makes the disambiguation problem easier.

— Reply to this email directly or view it on GitHub https://github.com/lightvector/arimaa-server/issues/124#issuecomment-174383597 .

mattj256 commented 8 years ago

I think switching to a 24hr clock would alone help a lot

I'm nowhere near having my dev environment set up.

Does this work? frontend/js/utils/Utils.js

timeToHHMMSS: function(time) {
    var date = new Date(time*1000);
    return date.toLocaleTimeString('en-GB');
},

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString

mattj256 commented 8 years ago

Was this fixed already? It's showing up in 24-hour clock on my machine.
(This is local dev. The playarimaa.org website is down.)

a

lightvector commented 8 years ago

I'm surprised - I don't recall fixing this. I now suspect I was just hallucinating the problem earlier.

The relevant code is in frontend/js/Utils.js:

timeToHHMMSS: function(time) { var date = new Date(time*1000); var hours = date.getHours(); var minutes = "0" + date.getMinutes(); var seconds = "0" + date.getSeconds(); var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2); return formattedTime; },

Looking up the documentation for the getHours function in javascript, it does appear that it returns a number from 0 to 23. So all is well for 12h vs 24h I think. Thanks for asking further into this.

It still remains, though, to show an indicator of how long ago if it was from an earlier day, although certainly this is is less of an issue than I thought it was.