You are here

public static function OfficeHoursDateHelper::getTimeFormat in Office Hours 8

Helper function to get the proper format_date() format from the settings.

For formatting options, see http://www.php.net/manual/en/function.date.php.

Parameters

string $time_format: Time format.

Return value

string Returns the time format.

2 calls to OfficeHoursDateHelper::getTimeFormat()
OfficeHoursFormatterTrait::formatSlots in src/OfficeHoursFormatterTrait.php
Formatter: format the office hours list.
OfficeHoursList::processOfficeHoursSlot in src/Element/OfficeHoursList.php
Process an individual element.

File

src/OfficeHoursDateHelper.php, line 36

Class

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

Namespace

Drupal\office_hours

Code

public static function getTimeFormat($time_format) {
  switch ($time_format) {
    case 'G':

      // 24hr without leading zero.
      $time_format = 'G:i';
      break;
    case 'H':

      // 24hr with leading zero.
      $time_format = 'H:i';
      break;
    case 'g':

      // 12hr am/pm without leading zero.
      $time_format = 'g:i a';
      break;
    case 'h':

      // 12hr am/pm with leading zero.
      $time_format = 'h:i a';
      break;
  }
  return $time_format;
}