You are here

function _calendar_systems_fix_whitespace in Calendar Systems 7.3

Same name and namespace in other branches
  1. 8 calendar_systems.helpers.inc \_calendar_systems_fix_whitespace()
  2. 6.3 calendar_systems.module \_calendar_systems_fix_whitespace()
  3. 6 calendar_systems.module \_calendar_systems_fix_whitespace()
  4. 7 calendar_systems.helpers.inc \_calendar_systems_fix_whitespace()
  5. 7.2 calendar_systems.helpers.inc \_calendar_systems_fix_whitespace()

Helper function

Parameters

$format:

$granularity:

Return value

string

1 call to _calendar_systems_fix_whitespace()
_calendar_systems_get_format in ./calendar_systems.module
Helper function

File

./calendar_systems.module, line 533
Contains Calendar Systems hook implementations and helpers.

Code

function _calendar_systems_fix_whitespace($format, $granularity) {
  $new_format = '';
  $list = _calendar_systems_get_date_format();

  //remove whitespaces from end
  $i = strlen($format) - 1;
  for (; $i >= 0; $i--) {
    $c = $format[$i];
    if (isset($list[$c])) {
      break;
    }
  }
  $format = substr($format, 0, $i + 1);

  //remove whitespaces from begining
  $i = 0;
  for (; $i < strlen($format); $i++) {
    $c = $format[$i];
    if (isset($list[$c])) {
      break;
    }
  }
  $new_format = substr($format, $i, strlen($format) - $i);
  return $new_format;
}