PageSourceSearch

https://pricechecker.ai/wp-content/plugins/pc-time-manager-ui-components/assets/frontend/js/pc-time-utils.js

js pricechecker.ai collected 2026-10-05 12:26:26 UTC 2,797 bytes, 81 lines download raw bytes

1export function isOneHourAhead(timeStr,dateStr){
2    // Parse the input time string
3    const [time, modifier] = timeStr.split(' ') ;
4    let [hours, minutes] = time.split(":").map(Number);
5
6    // Convert time from 12 hrs format to 24 hrs
7    if ( modifier.toLowerCase() === 'pm' && hours !== 12 ) {
8        hours += 12;
9    } else if ( modifier.toLowerString === 'am' && hours === 12 ) {
10        hours = 0;
11    }
12
13    // Ensure hours and minutes are two digits
14    hours = String(hours).padStart(2, '0');
15    minutes = String(minutes).padStart(2, '0');
16
17    if ( !isCurrentDate(hours+":"+minutes+":"+"00",dateStr) ) return true;
18
19    const givenTime = new Date();
20    givenTime.setHours(hours, minutes, 0, 0);
21
22    // Get the current date and time
23    const now = new Date();
24    const oneHourAhead = new Date(now.getTime() + 60 * 60 * 1000);
25
26    // Compare the given time with one hour ahead
27    return givenTime > oneHourAhead;
28}
29
30// function isCurrentDate(dateStr){
31
32//     try {
33//         if ( typeof dateStr === 'undefined' ){
34//             return false;
35//         }
36//         let inputDate = new Date(dateStr);
37//         let currentDate = new Date();
38
39//         // Normalize both dates to the same format (YYYY-MM-DD)
40//         let inputDateString = inputDate.toISOString().split('T')[0];
41//         let currentDateString = currentDate.toISOString().split('T')[0];
42
43//         return inputDateString === currentDateString;
44//     } catch (error){
45//         console.error(error);
46//         console.error("date value: " + dateStr );
47//     }
48// }
49
50function isCurrentDate(timeStr,dateStr) {
51    try {
52        if (typeof dateStr === 'undefined' || typeof timeStr === 'undefined') {
53            return false;
54        }
55        
56        // Combine date and time strings into a single ISO 8601 string
57        let inputDateTimeStr = dateStr + 'T' + timeStr;
58
59        let inputDate = new Date(inputDateTimeStr);
60        let currentDate = new Date();
61
62        // Get local date components
63        let inputDateString = inputDate.getFullYear() + '-' + 
64                              String(inputDate.getMonth() + 1).padStart(2, '0') + '-' + 
65                              String(inputDate.getDate()).padStart(2, '0');
66                              
67        let currentDateString = currentDate.getFullYear() + '-' + 
68                                String(currentDate.getMonth() + 1).padStart(2, '0') + '-' + 
69                                String(currentDate.getDate()).padStart(2, '0');
70
71        // console.log(inputDateString);
72        // console.log(currentDateString);
73
74
75        return inputDateString === currentDateString ;
76    } catch (error) {
77        console.error(error);
78        console.error("date value: " + dateStr + ", time value: " + timeStr);
79        return false;
80    }
81}

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.