You are here

public static function OfficeHoursDateHelper::formatTimeSlot in Office Hours 8

Formats a time slot.

Parameters

string $start: Start time.

string $end: End time.

string $format: Date format.

string $separator: Date separator.

Return value

string Returns formatted time.

1 call to OfficeHoursDateHelper::formatTimeSlot()
OfficeHoursFormatterTrait::formatSlots in src/OfficeHoursFormatterTrait.php
Formatter: format the office hours list.

File

src/OfficeHoursDateHelper.php, line 145

Class

OfficeHoursDateHelper
Defines lots of helpful functions for use in massaging dates.

Namespace

Drupal\office_hours

Code

public static function formatTimeSlot($start, $end, $format = 'G:i', $separator = ' - ') {
  $start_time = OfficeHoursDateHelper::format($start, $format, FALSE);
  $end_time = OfficeHoursDateHelper::format($end, $format, TRUE);
  if (!mb_strlen($start_time) && !mb_strlen($end_time)) {

    // Empty time fields.
    return '';
  }
  return $start_time . $separator . $end_time;
}