3 ms·
Show HN: sortByTimeAgo.js - A jQuery plugin I'm working on to sort by time ago.
- ibejoeb 14y agoOut of curiosity, what third-party APIs are you using that return "time ago" attributes but no standard date attribute (e.g, ISO 8601, RFC 822)? I hope never to have that misfortune. This would be great for scraping, though.
- cjstewart88 14y agoThis is the API that made me do it: http://api.ihackernews.com/page?format=jsonp http://api.ihackernews.com/page?format=jsonp I was using it along with reddits api to sort posts together on this website, http://www.hackerreads.com/ http://www.hackerreads.com/.
- dangrossman 14y agoThanks for sharing this. But why is it a jQuery plugin? It's a single function that iterates over an array, just as suited for a library or node.js module as a webpage; a dependency on a DOM library seems out of place.
- gbraad 14y agoSeems to be a wrong approach to me. Instead of using a timestamp it is sorted against 'English' indexof-ed strings. I would expect human-readable date formats are done afterwords on the sorted array itself, which would be a simple compare check. It is jQuery specific since it uses $.each
- cjstewart88 14y agoI would never make an API that returns time ago and force my users to sort that way. This was made because: http://api.ihackernews.com/page?format=jsonp http://api.ihackernews.com/page?format=jsonp
- gbraad 14y agoHad never seen this unofficial API. Ugh, postedAgo?! Should be a timestamp... As he mentions, it should be avail. Ask ronneroller to change/add it ;-)
- skrebbel 14y agojust guessing here: to attract the hordes of "jquery programmers" who don't know how to use a "javascript library"?
- cjstewart88 14y agoYou're probably right, this should not depend on jQuery. I'm the most comfortable with it and decided to just roll with it this way. I'll branch out and try making it not dependable on anything other than JavaScript. Thanks for the feedback.
- cjstewart88 14y agoThere's now a version that doesn't rely on jQuery, thanks for the feedback that led to me doing it :)