You are here

function system_date_time_settings in Drupal 5

Same name and namespace in other branches
  1. 6 modules/system/system.admin.inc \system_date_time_settings()
  2. 7 modules/system/system.admin.inc \system_date_time_settings()
1 string reference to 'system_date_time_settings'
system_menu in modules/system/system.module
Implementation of hook_menu().

File

modules/system/system.module, line 780
Configuration system that lets administrators modify the workings of the site.

Code

function system_date_time_settings() {

  // Date settings:
  $zones = _system_zonelist();

  // Date settings: possible date formats
  $dateshort = array(
    'Y-m-d H:i',
    'm/d/Y - H:i',
    'd/m/Y - H:i',
    'Y/m/d - H:i',
    'd.m.Y - H:i',
    'm/d/Y - g:ia',
    'd/m/Y - g:ia',
    'Y/m/d - g:ia',
    'M j Y - H:i',
    'j M Y - H:i',
    'Y M j - H:i',
    'M j Y - g:ia',
    'j M Y - g:ia',
    'Y M j - g:ia',
  );
  $datemedium = array(
    'D, Y-m-d H:i',
    'D, m/d/Y - H:i',
    'D, d/m/Y - H:i',
    'D, Y/m/d - H:i',
    'F j, Y - H:i',
    'j F, Y - H:i',
    'Y, F j - H:i',
    'D, m/d/Y - g:ia',
    'D, d/m/Y - g:ia',
    'D, Y/m/d - g:ia',
    'F j, Y - g:ia',
    'j F Y - g:ia',
    'Y, F j - g:ia',
    'j. F Y - G:i',
  );
  $datelong = array(
    'l, F j, Y - H:i',
    'l, j F, Y - H:i',
    'l, Y,  F j - H:i',
    'l, F j, Y - g:ia',
    'l, j F Y - g:ia',
    'l, Y,  F j - g:ia',
    'l, j. F Y - G:i',
  );

  // Date settings: construct choices for user
  foreach ($dateshort as $f) {
    $dateshortchoices[$f] = format_date(time(), 'custom', $f);
  }
  foreach ($datemedium as $f) {
    $datemediumchoices[$f] = format_date(time(), 'custom', $f);
  }
  foreach ($datelong as $f) {
    $datelongchoices[$f] = format_date(time(), 'custom', $f);
  }
  $form['date_default_timezone'] = array(
    '#type' => 'select',
    '#title' => t('Default time zone'),
    '#default_value' => variable_get('date_default_timezone', 0),
    '#options' => $zones,
    '#description' => t('Select the default site time zone.'),
  );
  $form['configurable_timezones'] = array(
    '#type' => 'radios',
    '#title' => t('Configurable time zones'),
    '#default_value' => variable_get('configurable_timezones', 1),
    '#options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    '#description' => t('Enable or disable user-configurable time zones. When enabled, users can set their own time zone and dates will be updated accordingly.'),
  );
  $form['date_format_short'] = array(
    '#type' => 'select',
    '#title' => t('Short date format'),
    '#default_value' => variable_get('date_format_short', $dateshort[1]),
    '#options' => $dateshortchoices,
    '#description' => t('The short format of date display.'),
  );
  $form['date_format_medium'] = array(
    '#type' => 'select',
    '#title' => t('Medium date format'),
    '#default_value' => variable_get('date_format_medium', $datemedium[1]),
    '#options' => $datemediumchoices,
    '#description' => t('The medium sized date display.'),
  );
  $form['date_format_long'] = array(
    '#type' => 'select',
    '#title' => t('Long date format'),
    '#default_value' => variable_get('date_format_long', $datelong[0]),
    '#options' => $datelongchoices,
    '#description' => t('Longer date format used for detailed display.'),
  );
  $form['date_first_day'] = array(
    '#type' => 'select',
    '#title' => t('First day of week'),
    '#default_value' => variable_get('date_first_day', 0),
    '#options' => array(
      0 => t('Sunday'),
      1 => t('Monday'),
      2 => t('Tuesday'),
      3 => t('Wednesday'),
      4 => t('Thursday'),
      5 => t('Friday'),
      6 => t('Saturday'),
    ),
    '#description' => t('The first day of the week for calendar views.'),
  );
  return system_settings_form($form);
}