Skip to content

Instantly share code, notes, and snippets.

@davidmroth
Created January 13, 2020 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmroth/6bae027047ec6fa71e8b34d29b7cb193 to your computer and use it in GitHub Desktop.
Save davidmroth/6bae027047ec6fa71e8b34d29b7cb193 to your computer and use it in GitHub Desktop.
Squarespace - Remove event date if between a specified time
$(document).ready(function() {
var getTimeValue = function(time) {
return Date.parse('01/01/2011 ' + time);
}
var ignoreAfter = '12:00:00 AM';
var ignoreBefore = '05:00:00 AM';
var allEventTimes = $('.eventlist-meta-time');
var test = allEventTimes.filter(function(idx, elm) {
var start = $(elm).find('.event-time-12hr .event-time-12hr-start').text();
var end = $(elm).find('.event-time-12hr .event-time-12hr-end').text();
if (start && end) {
if (
(getTimeValue(start) >= getTimeValue(ignoreAfter)) &&
(getTimeValue(end) <= getTimeValue(ignoreBefore))
) {
$(this).addClass('hideTime');
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment