function trackTimestamps(rate = 15000) {
    $(".js-watchable-timestamp").each(function () {
        let isShort = $(this).data("isShort");

        if (isShort) {
            moment
            .locale('en', {
                relativeTime: {
                    past: '%s ago',
                    s:  'just now',
                    ss: '%ss',
                    m:  '%dm',
                    mm: '%dm',
                    h:  '%dh',
                    hh: '%dh',
                    d:  '%dd',
                    dd: '%dd',
                    M:  '%dmo',
                    MM: '%dmo',
                    y:  '%dy',
                    yy: '%dy'
                }
            });
        }

        let timestamp = $(this).data("timestamp");
        if (timestamp < 1000000000000) { // <-- Potential y33.658k bug [that's a y2k joke]
            timestamp = timestamp * 1000; // convert from seconds to milliseconds
        }
        let future = false;
        if (timestamp > (Date.now())) {
            future = true;
        }

        let since = null;
        let maxDays = $(this).data("maxDays");
        if (maxDays && (timestamp < moment().valueOf() - (maxDays * 86400000))) {
        // > 2 weeks, change the message to that
            since = "over 2 weeks";
        } else {
        // < 2 weeks
            since = moment
                .utc(timestamp)
                .fromNow(true);
        }

        if ($(this).is("abbr")) {
            $(this).prop("title", (future ? "in " : "") + since + (!future ? " ago" : ""));
        } else {
            $(this).html(since);
        }
    });

    $(".js-timestamp").each(function () {
        let timestamp = $(this).data("timestamp");
        if (timestamp < 1000000000000) {
            timestamp = timestamp * 1000;
        }
        let format = ($(this).data("format") ? $(this).data("format") : "dddd, MMMM Do YYYY, h:mm a");
        let since  = moment.utc(timestamp).local().format(format);
        if ($(this).is("abbr")) {
            $(this).prop("title", since);
        } else {
            $(this).html(since);
        }
    });

    $(".js-timestamp-title").each(function () {
        let title = $(this).data("title");

        let timestamp = $(this).data("timestamp");
        if (timestamp < 1000000000000) {
            timestamp = timestamp * 1000;
        }
        let time = moment.utc(timestamp).local().format("dddd, MMMM Do YYYY, h:mm a");
        if (title) {
            $(this).prop("title", (title + ' ' + time));
        } else {
            $(this).prop("title", time);
        }
    });

    timestampUpdateInterval ? clearInterval(timestampUpdateInterval) : null;

    timestampUpdateInterval = setInterval(function () {
        $(".js-watchable-timestamp").each(function () {
            let timestamp = $(this).data("timestamp");
            if (timestamp < 1000000000000) {
                timestamp = timestamp * 1000; // convert from seconds to milliseconds
            }
            let future = false;
            if (timestamp > (Date.now())) {
                future = true;
            }

            let since = null;
            let maxDays = $(this).data("maxDays");
            if (maxDays && (timestamp < moment().valueOf() - (maxDays * 86400000))) {
            // > 2 weeks, change the message to that
                since = "over 2 weeks";
            } else {
            // < 2 weeks
                since = moment.utc(timestamp).fromNow(true);
            }

            if ($(this).is("abbr")) {
                $(this).prop("title", (future ? "in " : "") + since + (!future ? " ago" : ""));
            } else {
                $(this).html(since);
            }
        });
    }, rate);
}
/**
 * Tracks any timestamps on the page and prints how long since/until each timestamp's date.
 *
 * @param rate How frequently the timestamps should be updated.
 */
Tracks any timestamps on the page and prints how long since/until each timestamp's date.

@param rate How frequently the timestamps should be updated.
Tracks any timestamps on the page and prints how long since / until each timestamp ' s date . @param rate How frequently the timestamps should be updated .
function trackTimestamps(rate = 15000) {
    $(".js-watchable-timestamp").each(function () {
        let isShort = $(this).data("isShort");
        if (isShort) {
            moment
            .locale('en', {
                relativeTime: {
                    past: '%s ago',
                    s:  'just now',
                    ss: '%ss',
                    m:  '%dm',
                    mm: '%dm',
                    h:  '%dh',
                    hh: '%dh',
                    d:  '%dd',
                    dd: '%dd',
                    M:  '%dmo',
                    MM: '%dmo',
                    y:  '%dy',
                    yy: '%dy'
                }
            });
        }
        let timestamp = $(this).data("timestamp");
        if (timestamp < 1000000000000) { 
            timestamp = timestamp * 1000; 
        }
        let future = false;
        if (timestamp > (Date.now())) {
            future = true;
        }
        let since = null;
        let maxDays = $(this).data("maxDays");
        if (maxDays && (timestamp < moment().valueOf() - (maxDays * 86400000))) {
            since = "over 2 weeks";
        } else {
            since = moment
                .utc(timestamp)
                .fromNow(true);
        }
        if ($(this).is("abbr")) {
            $(this).prop("title", (future ? "in " : "") + since + (!future ? " ago" : ""));
        } else {
            $(this).html(since);
        }
    });
    $(".js-timestamp").each(function () {
        let timestamp = $(this).data("timestamp");
        if (timestamp < 1000000000000) {
            timestamp = timestamp * 1000;
        }
        let format = ($(this).data("format") ? $(this).data("format") : "dddd, MMMM Do YYYY, h:mm a");
        let since  = moment.utc(timestamp).local().format(format);
        if ($(this).is("abbr")) {
            $(this).prop("title", since);
        } else {
            $(this).html(since);
        }
    });
    $(".js-timestamp-title").each(function () {
        let title = $(this).data("title");
        let timestamp = $(this).data("timestamp");
        if (timestamp < 1000000000000) {
            timestamp = timestamp * 1000;
        }
        let time = moment.utc(timestamp).local().format("dddd, MMMM Do YYYY, h:mm a");
        if (title) {
            $(this).prop("title", (title + ' ' + time));
        } else {
            $(this).prop("title", time);
        }
    });
    timestampUpdateInterval ? clearInterval(timestampUpdateInterval) : null;
    timestampUpdateInterval = setInterval(function () {
        $(".js-watchable-timestamp").each(function () {
            let timestamp = $(this).data("timestamp");
            if (timestamp < 1000000000000) {
                timestamp = timestamp * 1000; 
            }
            let future = false;
            if (timestamp > (Date.now())) {
                future = true;
            }
            let since = null;
            let maxDays = $(this).data("maxDays");
            if (maxDays && (timestamp < moment().valueOf() - (maxDays * 86400000))) {
                since = "over 2 weeks";
            } else {
                since = moment.utc(timestamp).fromNow(true);
            }
            if ($(this).is("abbr")) {
                $(this).prop("title", (future ? "in " : "") + since + (!future ? " ago" : ""));
            } else {
                $(this).html(since);
            }
        });
    }, rate);
}
function trackTimestamps ( rate = 15000 ) { $ ( ".js-watchable-timestamp" ) . each ( function ( ) { let isShort = $ ( this ) . data ( "isShort" ) ; if ( isShort ) { moment . locale ( 'en' , { relativeTime : { past : '%s ago' , s : 'just now' , ss : '%ss' , m : '%dm' , mm : '%dm' , h : '%dh' , hh : '%dh' , d : '%dd' , dd : '%dd' , M : '%dmo' , MM : '%dmo' , y : '%dy' , yy : '%dy' } } ) ; } let timestamp = $ ( this ) . data ( "timestamp" ) ; if ( timestamp < 1000000000000 ) { timestamp = timestamp * 1000 ; } let future = false ; if ( timestamp > ( Date . now ( ) ) ) { future = true ; } let since = null ; let maxDays = $ ( this ) . data ( "maxDays" ) ; if ( maxDays && ( timestamp < moment ( ) . valueOf ( ) - ( maxDays * 86400000 ) ) ) { since = "over 2 weeks" ; } else { since = moment . utc ( timestamp ) . fromNow ( true ) ; } if ( $ ( this ) . is ( "abbr" ) ) { $ ( this ) . prop ( "title" , ( future ? "in " : "" ) + since + ( ! future ? " ago" : "" ) ) ; } else { $ ( this ) . html ( since ) ; } } ) ; $ ( ".js-timestamp" ) . each ( function ( ) { let timestamp = $ ( this ) . data ( "timestamp" ) ; if ( timestamp < 1000000000000 ) { timestamp = timestamp * 1000 ; } let format = ( $ ( this ) . data ( "format" ) ? $ ( this ) . data ( "format" ) : "dddd, MMMM Do YYYY, h:mm a" ) ; let since = moment . utc ( timestamp ) . local ( ) . format ( format ) ; if ( $ ( this ) . is ( "abbr" ) ) { $ ( this ) . prop ( "title" , since ) ; } else { $ ( this ) . html ( since ) ; } } ) ; $ ( ".js-timestamp-title" ) . each ( function ( ) { let title = $ ( this ) . data ( "title" ) ; let timestamp = $ ( this ) . data ( "timestamp" ) ; if ( timestamp < 1000000000000 ) { timestamp = timestamp * 1000 ; } let time = moment . utc ( timestamp ) . local ( ) . format ( "dddd, MMMM Do YYYY, h:mm a" ) ; if ( title ) { $ ( this ) . prop ( "title" , ( title + ' ' + time ) ) ; } else { $ ( this ) . prop ( "title" , time ) ; } } ) ; timestampUpdateInterval ? clearInterval ( timestampUpdateInterval ) : null ; timestampUpdateInterval = setInterval ( function ( ) { $ ( ".js-watchable-timestamp" ) . each ( function ( ) { let timestamp = $ ( this ) . data ( "timestamp" ) ; if ( timestamp < 1000000000000 ) { timestamp = timestamp * 1000 ; } let future = false ; if ( timestamp > ( Date . now ( ) ) ) { future = true ; } let since = null ; let maxDays = $ ( this ) . data ( "maxDays" ) ; if ( maxDays && ( timestamp < moment ( ) . valueOf ( ) - ( maxDays * 86400000 ) ) ) { since = "over 2 weeks" ; } else { since = moment . utc ( timestamp ) . fromNow ( true ) ; } if ( $ ( this ) . is ( "abbr" ) ) { $ ( this ) . prop ( "title" , ( future ? "in " : "" ) + since + ( ! future ? " ago" : "" ) ) ; } else { $ ( this ) . html ( since ) ; } } ) ; } , rate ) ; }
Tracks any timestamps on the page and prints how long since/until each timestamp's date.
Tracks any timestamps on the page and prints how long since / until each timestamp ' s date .
// <-- Potential y33.658k bug [that's a y2k joke]
 // convert from seconds to milliseconds
 // > 2 weeks, change the message to that
 // < 2 weeks
 // convert from seconds to milliseconds
 // > 2 weeks, change the message to that
 // < 2 weeks
