1/** 2 * @file Converts date strings to a "time ago" format upon document ready. 3 * @requires jQuery 4 */ 5 6$(document).ready(function () { 7 const reviewDate = $(".user-meta"); 8 reviewDate.each(function () { 9 const date = $(this).text(); 10 $(this).text(timeAgo(date)); 11 }); 12 13 /** 14 * Converts a date string in "YYYY/MM/DD" format to a relative "time ago" string. 15 * 16 * @param {string} date - The date string to convert. 17 * @returns {string} A string representing the time elapsed (e.g., "just now", "5 minutes ago"). 18 */ 19 20 function timeAgo(date) { 21 const [year, month, day] = date.split("-"); 22 const pastDate = new Date(Number(year), Number(month) - 1, Number(day)); 23 const now = new Date(); 24 const diffMs = now - pastDate; 25 26 const seconds = Math.floor(diffMs / 1000); 27 const minutes = Math.floor(seconds / 60); 28 const hours = Math.floor(minutes / 60); 29 const days = Math.floor(hours / 24); 30 const months = Math.floor(days / 30); 31 const years = Math.floor(months / 12); 32 33 if (seconds < 60) return "just now"; 34 if (minutes < 60) return `${minutes} minute${minutes !== 1 ? "s" : ""} ago`; 35 if (hours < 24) return `${hours} hour${hours !== 1 ? "s" : ""} ago`; 36 if (days < 30) return `${days} day${days !== 1 ? "s" : ""} ago`; 37 if (months < 12) return `${months} month${months !== 1 ? "s" : ""} ago`; 38 return `${years} year${years !== 1 ? "s" : ""} ago`; 39 } 40});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.