// requires moment.js

// on window load, run the changeTimestamps function.
$(window).load(function () {
    changeTimestamps();
    //if any html changes, call the changeTimestamps function.
    var observer = new MutationObserver(changeTimestamps);

    observer.observe(document, {
        attributes: true,
        childList: true,
        subtree: true,
        characterData: true
    });
});

//changes anything with the class timestamp from UTC to local time.
function changeTimestamps(){
    $(".timestamp").each(function(){
        if($(this).hasClass('local')){
            return;
        }
        $(this).addClass('local');

        var timestampText = this.textContent + " UTC";
        var localDate = moment(new Date(timestampText));

        var format = 'MMMM Do YYYY, h:mm:ss'
        if($(this).hasClass('date')){
            format = 'MMMM Do YYYY';            
        }
        
        //if the date cannot be parsed, ignore it and leave the text as-is. Otherwise, parse into local datetime format. 
        if(localDate.format(format) !== "Invalid date"){
            this.textContent = localDate.format(format);
        }
    });
}
@@ -1,502 +1,127 @@
 //
- requires moment.js%0A%0A// on window load, run the changeTimestamps function.%0A$(window).load(function () %7B%0A    changeTimestamps();%0A    //if any html changes, 
+changes timestamps from UTC to lo
 cal
-l
  t
-he changeTimestamps function.%0A    var observer = new MutationObserver(changeTimestamps);%0A%0A    observer.observe(document, %7B%0A        attributes: true,%0A        childList: true,%0A        subtree: true,%0A        characterData: true%0A    %7D);%0A%7D);%0A%0A//changes anything with the class timestamp from UTC to local time.%0Afunction changeTimestamps
+ime. Updates any data order variables for tables.%0A$(window).load(function 
 ()
+ 
 %7B%0A
+    
     
@@ -306,18 +306,196 @@
 tent
- + %22 UTC%22;
+;%0A%0A        //add sorting attribute, if it's part of a table it will be sorted by this instead of the nicely formatted timestamp.%0A        $(this).attr(%22data-order%22, timestampText);%0A        
 %0A   
@@ -544,16 +544,25 @@
 tampText
+ + %22 UTC%22
 ));%0A%0A   
@@ -964,8 +964,10 @@
    %7D);%0A%7D
+);

replace timestamps before sorting, with sorting attribute