You are here

public static function IntervalHandler::checkTime in DB Maintenance 8

Same name and namespace in other branches
  1. 7.2 src/Module/Interval/IntervalHandler.php \Drupal\db_maintenance\Module\Interval\IntervalHandler::checkTime()
  2. 2.0.x src/Module/Interval/IntervalHandler.php \Drupal\db_maintenance\Module\Interval\IntervalHandler::checkTime()

Checks, if $time is in 24 hour format H:i (HH:MM) like 23:30 or 01:00.

1 call to IntervalHandler::checkTime()
DbMaintenanceAdminSettings::validateForm in src/Form/DbMaintenanceAdminSettings.php
Form validation handler.

File

src/Module/Interval/IntervalHandler.php, line 82
IntervalHandler class.

Class

IntervalHandler
IntervalHandler class.

Namespace

Drupal\db_maintenance\Module\Interval

Code

public static function checkTime($time) {
  if (!isset($time)) {
    return FALSE;
  }
  if (mb_strlen($time) != 5) {
    return FALSE;
  }
  $hour = (int) mb_substr($time, 0, 2);
  $minute = (int) mb_substr($time, 3, 2);
  if ($hour < 0 || $hour > 23) {
    return FALSE;
  }
  if ($minute < 0 || $minute > 59) {
    return FALSE;
  }
  return TRUE;
}