You are here

function _datex_date_views_argument_handler_simple::_datex in Datex 7.3

Handle the date and convert it accordingly.

1 call to _datex_date_views_argument_handler_simple::_datex()
_datex_date_views_argument_handler_simple::query in ./datex.views.inc
Fix the query for localized dates.

File

./datex.views.inc, line 446
Datex views integration.

Class

_datex_date_views_argument_handler_simple
Copied from date_views module. So we have no hard dependency on it.

Code

function _datex() {
  if (isset($this->datexed)) {
    return;
  }
  $this->datexed = TRUE;
  $schema = _datex_element_schema($this->options);
  if ($schema === 'disabled') {
    return;
  }
  $calendar = datex_factory(NULL, _datex_language_calendar_name($schema));
  if (!$calendar) {
    return;
  }
  $gr = $this->options['granularity'];
  $arg = str_replace('-', '', $this->argument);
  switch ($gr) {
    case 'year':
      $calendar
        ->setDateLocale($arg, 6, 24);
      $this->argument = $calendar
        ->xFormat('Y');
      break;
    case 'month':
      if (strlen($arg) < 5) {
        return;
      }
      $calendar
        ->setDateLocale(substr($arg, 0, 4), substr($arg, 4, 6), 24);
      $this->argument = $calendar
        ->xFormat('Y-m');
      break;
    case 'day':
      if (strlen($arg) < 7) {
        return;
      }
      $calendar
        ->setDateLocale(substr($arg, 0, 4), substr($arg, 4, 6), substr($argc, 6, 8));
      $this->argument = $calendar
        ->xFormat('Y-m-d');
      break;
  }
}