function locale_date_format_save

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 locale_date_format_save()
locale_date_format_form_submit in modules/locale/locale.admin.inc
Submit handler for configuring localized date formats on the locale_date_format_form.

File

includes/locale.inc, line 2428

Code

function locale_date_format_save($langcode, $type, $format) {
    $locale_format = array();
    $locale_format['language'] = $langcode;
    $locale_format['type'] = $type;
    $locale_format['format'] = $format;
    $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE language = :langcode AND type = :type', 0, 1, array(
        ':langcode' => $langcode,
        ':type' => $type,
    ))->fetchField();
    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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.