• Asalam Alaikum,

    I encountered an issue while uploading the CSV prayer times table, where valid times were flagged as invalid. I traced the issue to the is24Hours($row) function in validator.php in wp-content/plugins/daily-prayer-time-for-mosques/Models:

    Below the modified code using preg_match():

    private function is24Hours($row)
        {
            $afternoonPrayers = array($row[6], $row[7], $row[8], $row[9], $row[10], $row[11], $row[12]);
            
            foreach($afternoonPrayers as $time) {
               //  echo $time;   
                if (!preg_match('#^([01]?[0-9]|2[0-3]):[0-5][0-9]?$#', $time))
                {
                     echo "<h3 class='dptCenter ui-state-error'>$time is not in 24 hour time format for date: ". esc_html( $row[0] ) ."
                            </br> You must follow 24 hours time format, valid time format is <span class='green'>HH:MM</span></h3>";
                    return false;
                }
                
                /* old code */
                /*
    
                $firstPart = explode(':', $time);
                if ($firstPart[0] !== '00' && (int)$firstPart[0] < 12) {
                    echo $firstPart[0] . $firstPart[1];
                    echo "<h3 class='dptCenter ui-state-error'>$time is not in 24 hour time format for date: ". esc_html( $row[0] ) ."
                            </br> You must follow 24 hours time format, valid time format is <span class='green'>HH:MM</span></h3>";
                    return false;
                }
                */
            }
    
            return true;
        }

    Hope this helps!
    Jamal

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author mmrs151

    (@mmrs151)

    Walaikum Assalam wa rahmatullah my dear brother Jamal,

    And jazakallahu khair for your time to help fixing issues within the plugin.

    I make dua to have brothers like you, who can carry on this plugin after my death inshaaAllah.

    Can you please send me your csv too so I can see the problem first and test it thoroughly.

    Mustafiz.

    Thread Starter jamal1wp

    (@jamal1wp)

    Asalam Alaikum Br. Mustafiz,

    I sent you a sample CSV to [email protected]

    JAK,
    Jamal

    Plugin Author mmrs151

    (@mmrs151)

    Jazakallah for that.

    The csv worked in mine without any issues.
    I understand the improvement of your code. But could you please share with me what did not work on your csv with the previous code.

    Duas
    Mustafiz.

    Thread Starter jamal1wp

    (@jamal1wp)

    Asalam Alaikum,

    It seems to be working now; I did not write exactly the time that it did not verify correctly, but it was something like 10:30. It could have been an issue with WordPress and an update fixed it. Anyway, you are welcome to use the improved function which should work flawlessly and efficiently.

    Jamal

    • This reply was modified 3 years, 4 months ago by jamal1wp.
    Thread Starter jamal1wp

    (@jamal1wp)

    Asalam Alaikum,

    Actually, just now I got the validation message:

    10:29 is not in 24 hour time format for date: 1/1/2021
    You must follow 24 hours time format, valid time format is HH:MM

    It failed on the the first line, 7th value:

    “d_date”,”fajr_begins”,”fajr_jamah”,”sunrise”,”zuhr_begins”,”zuhr_jamah”,”asr_mithl_1″,”asr_mithl_2″,”asr_jamah”,”maghrib_begins”,”maghrib_jamah”,”isha_begins”,”isha_jamah”,”is_ramadan”,”hijri_date”
    “1/1/2021″,”23:58″,”00:23″,”01:00″,”07:04″,”12:30″,”10:29″,”15:00″,”15:00″,”13:07″,”13:12″,”14:09″,”19:45″,”0″,”0”

    Jamal

    Plugin Author mmrs151

    (@mmrs151)

    Assalamualaikum dear brother Jamal,

    I think there was a mistake in the csv, Asr mithl 1 can never be 10pm.
    I think I advised masjid who do not publish both Asr time to use same time for both Asr mithl, which was not the case in the csv.

    As I also mentioned, your preg function works correctly just correctly too but your preg funciton should stop this csv with a validation error too.

    Mustafiz.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fix for is24Hours function’ is closed to new replies.