1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ 2let window = _____WB$wombat$assign$function_____("window"); 3let self = _____WB$wombat$assign$function_____("self"); 4let document = _____WB$wombat$assign$function_____("document"); 5let location = _____WB$wombat$assign$function_____("location"); 6let top = _____WB$wombat$assign$function_____("top"); 7let parent = _____WB$wombat$assign$function_____("parent"); 8let frames = _____WB$wombat$assign$function_____("frames"); 9let opens = _____WB$wombat$assign$function_____("opens"); 10function isInRange( 11 startTime, 12 endTime, 13 allDayEnabled = false, 14 settingsRrule, 15 timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone 16) { 17 const now = new Date(); 18 let currentTime = new Date(now.toLocaleString('en-US', { timeZone })); 19 20 // If all day is true, adjust the start and end times to be full day 21 if (allDayEnabled) { 22 startTime.setHours(0, 0, 0, 0); 23 endTime.setHours(23, 59, 59, 999); 24 } 25 26 // Convert the times to the same timezone as the conditionTimezone 27 startTime = new Date(startTime.toLocaleString('en-US', { timeZone })); 28 endTime = new Date(endTime.toLocaleString('en-US', { timeZone })); 29 30 if (settingsRrule && rrule) { 31 //rrule is a 3rd party library to parse rrule strings 32 const recurringRule = rrule.rrulestr(settingsRrule); 33 recurringRule.options = { 34 ...recurringRule.options, 35 tzid: timeZone, 36 dtstart: 37 startTime < recurringRule.options.dtstart 38 ? startTime 39 : recurringRule.options.dtstart, 40 until: 41 endTime > recurringRule.origOptions.until 42 ? endTime 43 : recurringRule.origOptions.until, 44 }; 45 46 const allOccurrences = recurringRule.all(); 47 return allOccurrences.some((occurrence) => 48 compareDates(currentTime, occurrence, allDayEnabled) 49 ); 50 } 51 52 return ( 53 compareDatesIgnoringSeconds(currentTime, startTime) >= 0 && 54 compareDatesIgnoringSeconds(currentTime, endTime) <= 0 55 ); 56} 57 58function shouldShowRuleObjectForDateTimeRange( 59 ruleObjName, 60 settings, 61 actionType 62) { 63 const settingsStartTime = new Date(settings.start_time); 64 const settingsEndTime = new Date(settings.end_time); 65 const settingsAllDayEnabled = parseBoolean(settings.all_day_enabled); 66 const settingsRrule = settings.rrule; 67 const settingsTimeZone = settings.timezone; 68 69 if (settingsStartTime && settingsEndTime) { 70 const cookieName = getSmartRuleCookieName(ruleObjName, actionType); 71 return ( 72 isInRange( 73 settingsStartTime, 74 settingsEndTime, 75 settingsAllDayEnabled, 76 settingsRrule, 77 settingsTimeZone 78 ) && 79 //if the rule was already shown we shouldn't show it again until the ttl time when cookie expires 80 getCookie(cookieName) === null && 81 // there is no cookie of the same action type - site visitor already saw this action 82 !hasCookieOfType(actionType) 83 ); 84 } 85 86 //if there is no start_time, end_time, all_day_enabled, timezone in settings it means 87 // that the condition is not date time range, and we need to disregard this conditions 88 return true; 89} 90 91function compareDates(date1, date2, allDay) { 92 const d1 = new Date(date1); 93 const d2 = new Date(date2); 94 95 if (allDay) { 96 const year1 = d1.getFullYear(); 97 const month1 = d1.getMonth(); 98 const day1 = d1.getDate(); 99 100 const year2 = d2.getFullYear(); 101 const month2 = d2.getMonth(); 102 const day2 = d2.getDate(); 103 104 return year1 === year2 && month1 === month2 && day1 === day2; 105 } else { 106 d1.setSeconds(0, 0); 107 d2.setSeconds(0, 0); 108 109 return d1.getTime() === d2.getTime(); 110 } 111} 112 113function compareDatesIgnoringSeconds(date1, date2) { 114 let d1 = new Date(date1.getTime()); 115 let d2 = new Date(date2.getTime()); 116 117 d1.setSeconds(0, 0); 118 d2.setSeconds(0, 0); 119 120 if (d1.getTime() === d2.getTime()) { 121 return 0; 122 } else if (d1.getTime() < d2.getTime()) { 123 return -1; //d1 is earlier than d2 124 } else { 125 return 1; //d1 is later than d2 126 } 127} 128 129}
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.