News for hackers. Stuff that matters.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by MichaelApproved on Thursday July 26, 2012 @01:16PM (#4297242)
This is such a minor tweak that I can't see how it's worth trouble of downloading even a byte of extra code to get it done.

Please correct me if I'm wrong.

Edit: "minor tweak" in terms of efficiency. The processing power saved by making it "smart" is probably less than what it takes to download the extra code.

Re:Smart Time Ago: a new JS lib to update relative timestamp... by yehanyin on Thursday July 26, 2012 @01:39PM (#4297437)
It depends on the application itself. For pages which user will only stay for few minutes, no much more efficiency gained. But for realtime apps which user will keep the page open for hours/days, it will improve a lot. And for apps which have more read than write, it will also improve a lot. BTW, I'm not sure whether I catch you about the "extra code". It's a replacement with less than 1KB difference in size.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by MichaelApproved on Thursday July 26, 2012 @06:06PM (#4298999)
Even 1kb seems like too much. The processing power to handle the time ago logic is so small, having to download 1kb of data more probably takes more processing power than you're saving.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by taude on Thursday July 26, 2012 @01:25PM (#4297312)
The regular timeago is on Github: https://github.com/rmm5t/jquery-timeago.

I don't see the need for a new project for something like a tweak like this. Seems like a reasonable pull request for the timeago folks???

Re:Smart Time Ago: a new JS lib to update relative timestamp... by poshboytl on Thursday July 26, 2012 @01:38PM (#4297427)
Yup. Ryan did a great job on the timeago lib. We have ever discussed about the pull request but finally find that we changed lots of the logic about how to deal with the relative timestamp. So we started a new one to give an optional choice.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by NelsonMinar on Thursday July 26, 2012 @02:24PM (#4297729)
Javascript relative time displays have hilarious results if the web browser's clock is set incorrectly. That's mostly not a modern problem thanks to NTP being baked into modern consumer OSes but it can be terribly confusing if you have a misconfigured client.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by saurik on Thursday July 26, 2012 @02:55PM (#4297908)
The simple solution to this is that the server sends a reference time along with the timestamps: when the page loads you calculate the drift from the local time to the reference time, and then adjust local time to server time when you update relative timestamps.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by latchkey on Thursday July 26, 2012 @03:00PM (#4297924)
I just use http://momentjs.com/

Does timeago (with localizations) and more in one tiny library.

Re:Smart Time Ago: a new JS lib to update relative timestamp... by yehanyin on Thursday July 26, 2012 @03:34PM (#4298125)
It's different. While momentjs focus on date parsing, manipulating and formatting, smart-time-ago is the lib to update the relative timestamps in time on the page.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by latchkey on Thursday July 26, 2012 @03:38PM (#4298154)
Moment does both functions and 99% of the time that you're working with dates in an app, you're going to need both. Also, Moment is localized and has a fairly large community around it. The world doesn't need yet another timeago.
Re:Smart Time Ago: a new JS lib to update relative timestamp... by combataircraft on Thursday July 26, 2012 @01:53PM (#4297532)
you guys might be interested at this; https://github.com/azer/relative-date
Re:Smart Time Ago: a new JS lib to update relative timestamp... by poshboytl on Thursday July 26, 2012 @02:14PM (#4297652)
It looks interesting. Thanks for the info. Just watched. :D