Index: date_format/date_format.info
===================================================================
--- date_format/date_format.info	(revision 0)
+++ date_format/date_format.info	(revision 0)
@@ -0,0 +1,6 @@
+; $Id$
+name = Date Format
+description = Allows the site admin to configure multiple formats for date/time display to taylor dates for a specific locale or audience.
+package = Date/Time
+dependencies[] = date_api
+core = 6.x
Index: date_format/date_format.module
===================================================================
--- date_format/date_format.module	(revision 0)
+++ date_format/date_format.module	(revision 0)
@@ -0,0 +1,96 @@
+<?php
+// $Id$
+/**
+ * @file
+ * 
+ * TODO: Add a hook to allow modules to add their own formats, with callbacks to go to/from more complicated formats (such as alternate calendars)
+ */
+
+/**
+ * Implementation of hook_form_alter().
+ *
+ * Override system handling of date fromat selection.
+ */
+function date_format_form_alter(&$form, &$form_state, $form_id) {
+  if ($form_id == 'system_date_time_settings') {
+    $form['date_formats'] = array(
+      '#title' => 'Formatting',
+      '#type' => 'fieldset',
+      '#tree' => TRUE,
+      '#attributes' => array('class' => 'date-format-settings'),
+    );
+    
+    // Add custom formats
+    $result = db_query('SELECT * FROM {date_format}');
+    while ($format = db_fetch_object($result)) {
+      $formats[] = $format;
+    }
+    
+    // TODO: It would be more Drupally to do this on a separate page or add AHAH, rather than "save for more"
+    $format = new stdclass();
+    $format->dfid = 'new';
+    $formats[] = $format;
+    
+    foreach ($formats as $format) {
+      date_format_format_fields(&$form, $format);
+    }
+
+    $form['#submit'][] = 'date_format_date_time_settings_submit';
+  }
+}
+
+function date_format_format_fields(&$form, $format) {
+  $options = date_format_options();
+  $options['custom'] = t('Custom');
+  $form['date_formats'][$format->dfid]['title'] = array(
+    '#title' => t('Date format name'),
+    '#type' => 'textfield',
+    '#default_value' => check_plain($format->title),
+    '#size' => 20,
+    '#prefix' => '<div class="date-format-title">', 
+    '#suffix' => '</div>', 
+  );
+  $form['date_formats'][$format->dfid]['format'] = array(
+    '#title' => t('Date display'),
+    '#type' => 'select',
+    '#options' => $options,
+    '#multiple' => false,
+  );
+  // TODO: Add a little javascript to hide this until 'Custom' is selected
+  $form['date_formats'][$format->dfid]['custom'] = array(
+    '#title' => t('Custom display format'),
+    '#type' => 'textfield',
+    '#size' => 20,
+  );
+  // TODO: Make delete links actually work
+  $form['date_formats'][$format->dfid]['delete'] = array(
+    '#value' => '<div class="date-format-delete">' . l('delete', 'admin/settings/date-time/delete/' . $format->dfid) . '</div>',
+  );
+  
+  // Set for existing formats, using 'custom' if it is not a standard format 
+  if (isset($options[$format->format])) {
+    $form['date_formats'][$format->dfid]['format']['#default_value'] = check_plain($format->format);
+  }
+  else {
+    $form['date_formats'][$format->dfid]['format']['#default_value'] = 'custom';
+    $form['date_formats'][$format->dfid]['custom']['#default_value'] = check_plain($format->format);
+  }
+}
+
+function date_format_date_time_settings_submit($form, &$form_state) {
+  foreach ($form_state['values']['date_formats'] as $dfid => $format) {
+    // If 'custom' is selected and custom text field is completed we store that
+    if ($format['format'] == 'custom' && !empty($format['custom'])) {
+      $format['format'] = $format['custom'];
+    }
+    $format['dfid'] = $dfid;
+    if ($format['dfid'] == 'new' && !empty($format['title'])) {
+      drupal_write_record('date_format', $format);
+    }
+    else {
+      drupal_write_record('date_format', $format, 'dfid');
+    }
+  }
+  // Unset, to prevent this getting saved as a variable
+  unset($form_state['values']['date_formats']);
+}
Index: date_format/date_format.install
===================================================================
--- date_format/date_format.install	(revision 0)
+++ date_format/date_format.install	(revision 0)
@@ -0,0 +1,43 @@
+<?php
+// $Id$
+
+function date_format_schema() {
+  $schema['date_format'] = array(
+    'description' => t('For storing configured date formats.'),
+    'fields' => array(
+      'dfid' => array(
+        'description' => t('The primary identifier for a date format.'),
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE
+      ),
+      'title' => array(
+        'description' => t('Name of the date format.'),
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
+      'format' => array(
+        'description' => t('The date format string.'),
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array('dfid'),
+  );
+  
+  return $schema;
+}
+
+
+function date_format_install() {
+  drupal_install_schema('date_format');
+}
+
+function date_format_uninstall() {
+  drupal_uninstall_schema('date_format');
+  $ret = array();
+//  variable_del('');
+  return $ret;
+}
\ No newline at end of file
Index: date.css
===================================================================
--- date.css	(revision 15)
+++ date.css	(working copy)
@@ -141,4 +141,17 @@
 .date-clear-block {
   display: block;
 }
-/* End hide from IE-mac */
\ No newline at end of file
+/* End hide from IE-mac */
+
+.date-format-settings .form-item {
+  float: left;
+  margin-right: 1em;
+}
+
+.date-format-settings .date-format-title {
+  clear: left;
+}
+
+.date-format-settings .date-format-delete {
+  padding-top: 3em;
+}
\ No newline at end of file
Index: date/date_admin.inc
===================================================================
--- date/date_admin.inc	(revision 15)
+++ date/date_admin.inc	(working copy)
@@ -489,18 +489,3 @@
     'none' => t('No time zone conversion'),
     );
 }
-
-/**
- * Get an example date and make sure the difference between
- * month and day and 12 and 24 hours will be clear.
- */
-function date_example_date() {
-  $now = date_now();
-  if (date_format($now, 'm') == date_format($now, 'd')) {
-    date_modify($now, '+1 day');
-  }
-  if (date_format($now, 'H') == date_format($now, 'h')) {
-    date_modify($now, '+12 hours');
-  }
-  return $now;
-}
\ No newline at end of file
