You are here

static function Helpers::calendar_systems_get_calendar_instance in Calendar Systems 8.2

Gets an instance of the calendar object for the selected calendar system acording to the settings or the passed arguments

Parameters

null $calendar_system:

null $language:

Return value

\cmfcCalendarV1 Calendar object or default on fail.

2 calls to Helpers::calendar_systems_get_calendar_instance()
CalendarSystemsDateFormatter::format in src/Services/DateFormatter/CalendarSystemsDateFormatter.php
Formats a date, using a date type or a custom date format string.
Helpers::calendar_systems_plugins in src/Helpers.php
Internal helper which defines all available calendars manually.

File

src/Helpers.php, line 114
Contains \Drupal\calendar_systems.

Class

Helpers

Namespace

Drupal\calendar_systems

Code

static function calendar_systems_get_calendar_instance($calendar_system = NULL, $language = NULL) {
  if (is_null($calendar_system)) {
    $calendar_system = self::calendar_systems_get_calendar_system_name($language);
  }
  if ($calendar_system == 'default') {
    $calendar_system = 'gregorian';
  }
  $calendar = Calendar::factory('v1', array(
    'name' => $calendar_system,
  ));
  return $calendar;
}