-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduleTimes.js
More file actions
32 lines (25 loc) · 1.25 KB
/
scheduleTimes.js
File metadata and controls
32 lines (25 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Get the current time
var currentTime = new Date();
// Get all elements with the class 'match'
var matches = document.querySelectorAll('.match');
// Iterate over each match
matches.forEach(function(match) {
// Get the match time element within the match
var matchTimeElement = match.querySelector('.match-time');
// Get the UTC time string from the 'data-utc' attribute of the match time element
var utcTimeString = matchTimeElement.getAttribute('data-utc');
// Create a new Date object from the UTC time string
var utcDate = new Date(utcTimeString);
// Add one hour to the match time
var matchTimePlusOneHour = new Date(utcDate.getTime() + 60 * 120 * 1000); //set to 2 hours for now
// Check if the current time is more than an hour past the match time
if (currentTime > matchTimePlusOneHour) {
// Hide the entire match
match.style.display = 'none';
} else {
// Convert UTC time to local time
var localTime = utcDate.toLocaleTimeString(undefined, {month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZoneName: 'short'});
// Update the match time element with the local time
matchTimeElement.textContent = localTime;
}
});