You are here

function date_api_set_variables in Date 6.2

Same name and namespace in other branches
  1. 5.2 date_api.install \date_api_set_variables()
  2. 7.3 date_api/date_api.install \date_api_set_variables()
  3. 7 date_api/date_api.install \date_api_set_variables()
  4. 7.2 date_api/date_api.install \date_api_set_variables()
3 calls to date_api_set_variables()
date_api_enable in ./date_api.install
Implementation of hook_enable().
date_api_install in ./date_api.install
Implementation of hook_install().
date_api_update_6000 in ./date_api.install
Make sure all the appropriate modules get enabled. Repeated again just to be sure they are set.

File

./date_api.install, line 3

Code

function date_api_set_variables() {

  // Set absolute minimum and maximum year for dates on this site.
  // There is actually no maximum and minimum year in PHP 5, but a date with
  // a year less than 0 would result in negative ISO and DATETIME dates,
  // like -1250-01-01T00:00:00, which probably won't make sense or work
  // correctly anywhere.
  //
  // The odd construct of using variable_get() instead of variable_set()
  // is so we don't accidentally write over an existing value. If
  // no value is set, variable_get() will set it.
  variable_get('date_max_year', 4000);
  variable_get('date_min_year', 1);
  variable_get('date_php_min_year', 1901);

  // Set an API version in a way that other modules can test for compatibility.
  variable_set('date_api_version', '5.2');
  if (version_compare(PHP_VERSION, '5.2', '<') && !module_exists('date_php4')) {
    module_enable(array(
      'date_php4',
    ));
  }

  // The timezone module was originally going to be optional
  // but too many things break without it.
  if (!module_exists('date_timezone')) {
    module_enable(array(
      'date_timezone',
    ));
  }

  // NULL is used for the default setting of date_default_timezone_name
  // to have a way to tell that no site timezone name has been implemented.
  // Otherwise, many functions would use 'UTC' incorrectly and
  // produce unreliable and odd results. This way functions can test for a
  // value and not use this if it is empty.
  //
  // The odd construct of using variable_get() instead of variable_set()
  // is so we don't accidentally write over an existing value. If
  // no value is set, variable_get() will set it to NULL.
  variable_get('date_default_timezone_name', NULL);
}