function locale_update_8016

Converts localized date formats.

Related topics

File

drupal/core/modules/locale/locale.install, line 950
Install, update, and uninstall functions for the Locale module.

Code

function locale_update_8016() {
  $configs = array();

  // Fetch all date types from {date_format_type}.
  $result = db_query('SELECT * FROM {date_format_locale}');
  foreach ($result as $format) {
    $language = $format->language;

    // Create config objects for the language if not yet done.
    if (!isset($configs[$language])) {
      $configs[$language] = config('locale.config.' . $language . '.system.date');
    }
    $configs[$language]
      ->set('formats.' . $format->type . '.pattern.php', $format->format);
  }

  // Save all instantiated config objects.
  foreach ($configs as $config) {
    $config
      ->save();
  }
}