Created
November 28, 2012 08:59
-
-
Save jacobh/4160002 to your computer and use it in GitHub Desktop.
little wrapper over moment.js to turn it into a jquery plugin for relative times.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.relativize = (format='MMM D, YYYY at hh:mma') -> | |
for date in this | |
$date = $ date | |
if $date.attr 'unix_timestamp' | |
this_moment = moment.unix $date.attr 'unix_timestamp' | |
else | |
this_moment = moment $date.text(), FORMAT | |
$date.attr 'unix_timestamp', this_moment.unix() | |
$date.text this_moment.fromNow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment