You are here

function date_locale_locale_format_save in Date 6.2

Save locale specific date formats to the database.

Parameters

$langcode: Language code, can be 2 characters, e.g. 'en' or 5 characters, e.g. 'en-CA'.

$type: Date format type, e.g. 'short', 'medium'.

$format: The date format string.

1 call to date_locale_locale_format_save()
date_locale_format_form_formats_submit in date_locale/date_locale.module
Submit handler for choosing a language on the date_locale_format_form.

File

date_locale/date_locale.module, line 280
Enable different locales to have their own date formats.

Code

function date_locale_locale_format_save($langcode, $type, $format) {
  $locale_format = array();
  $locale_format['language'] = $langcode;
  $locale_format['type'] = $type;
  $locale_format['format'] = $format;
  $is_existing = db_result(db_query("SELECT COUNT(*) FROM {date_format_locale} WHERE language = '%s' AND type = '%s'", $langcode, $type));
  if ($is_existing) {
    $keys = array(
      'type',
      'language',
    );
    drupal_write_record('date_format_locale', $locale_format, $keys);
  }
  else {
    drupal_write_record('date_format_locale', $locale_format);
  }
}