PageSourceSearch

https://bitrebels.com/wp-content/themes/magone/assets/js/relative-time.js

js bitrebels.com collected 2026-10-01 08:36:27 UTC 1,538 bytes, 59 lines download raw bytes

1(function(){
2	function plural(n, singular, plural){
3		return n === 1 ? singular : plural;
4	}
5
6	function updateTimes(){
7		const now = Date.now();
8
9		document.querySelectorAll('.published-time').forEach(el => {
10			const published = new Date(el.dataset.published).getTime();
11			let diff = Math.max(0, now - published);
12
13			const second = 1000;
14			const minute = 60 * second;
15			const hour   = 60 * minute;
16			const day    = 24 * hour;
17			const week   = 7 * day;
18			const month  = 30 * day;
19			const year   = 365 * day;
20
21			let value, label;
22
23			if (diff < minute) {
24				value = Math.max(1, Math.floor(diff / second));
25				label = plural(value, 'second ago', 'seconds ago');
26			}
27			else if (diff < hour) {
28				value = Math.floor(diff / minute);
29				label = plural(value, 'minute ago', 'minutes ago');
30			}
31			else if (diff < day) {
32				value = Math.floor(diff / hour);
33				label = plural(value, 'hour ago', 'hours ago');
34			}
35			else if (diff < week) {
36				value = Math.floor(diff / day);
37				label = plural(value, 'day ago', 'days ago');
38			}
39			else if (diff < month) {
40				value = Math.floor(diff / week);
41				label = plural(value, 'week ago', 'weeks ago');
42			}
43			else if (diff < year) {
44				value = Math.floor(diff / month);
45				label = plural(value, 'month ago', 'months ago');
46			}
47			else {
48				value = Math.floor(diff / year);
49				label = plural(value, 'year ago', 'years ago');
50			}
51
52			el.textContent = value + ' ' + label;
53			el.classList.remove('is-hydrating');
54		});
55	}
56
57	updateTimes();
58	setInterval(updateTimes, 60000);
59})();

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.