You are here

private function MerciOpenHoursConstraintValidator::renderOfficeHours in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2

1 call to MerciOpenHoursConstraintValidator::renderOfficeHours()
MerciOpenHoursConstraintValidator::validate in src/Plugin/Validation/Constraint/MerciOpenHoursConstraintValidator.php

File

src/Plugin/Validation/Constraint/MerciOpenHoursConstraintValidator.php, line 21
Contains \Drupal\merci\Plugin\Validation\Constraint\MerciOpenHoursConstraintValidator.

Class

MerciOpenHoursConstraintValidator
Checks for conflicts when validating a entity with reservable items.

Namespace

Drupal\merci\Plugin\Validation\Constraint

Code

private function renderOfficeHours($open_hours, $format = 'g:ia', $divider = '-') {
  $starthours = substr('0000' . $open_hours->starthours, -4);
  $endhours = substr('0000' . $open_hours->endhours, -4);
  $start = DrupalDateTime::createFromFormat('Gi', $starthours);
  $end = DrupalDateTime::createFromFormat('Gi', $endhours);
  return $start
    ->format($format) . $divider . $end
    ->format($format);
}