Skip to content

Commit

Permalink
Merge pull request #671 from localgovdrupal/feature/3.x-gds-date-format
Browse files Browse the repository at this point in the history
  • Loading branch information
finnlewis authored Jan 30, 2024
2 parents 97d4fa0 + afc2d02 commit 2925d6c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/install/core.date_format.long.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dependencies: { }
id: long
label: 'Default long date'
locked: false
pattern: 'l j F Y - g:ia'
pattern: 'l j F Y \a\t g:ia'
2 changes: 1 addition & 1 deletion config/install/core.date_format.medium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dependencies: { }
id: medium
label: 'Default medium date'
locked: false
pattern: 'D, d/m/Y - g:ia'
pattern: 'D d/m/Y g:ia'
2 changes: 1 addition & 1 deletion config/install/core.date_format.short.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dependencies: { }
id: short
label: 'Default short date'
locked: false
pattern: 'd/m/Y - g:ia'
pattern: 'd/m/Y g:ia'
22 changes: 22 additions & 0 deletions localgov.install
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,25 @@ function localgov_update_9501() {
\Drupal::service('theme_installer')->install(['stable9']);
}
}

/**
* Update default date formats to GDS if they haven't been changed.
*/
function localgov_update_9502() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('core.date_format.long');
if ($config->get('pattern') == 'l j F Y - g:ia') {
$config->set('pattern', 'l j F Y \a\t g:ia');
$config->save(TRUE);
}
$config = $config_factory->getEditable('core.date_format.medium');
if ($config->get('pattern') == 'D, d/m/Y - g:ia') {
$config->set('pattern', 'D d/m/Y g:ia');
$config->save(TRUE);
}
$config = $config_factory->getEditable('core.date_format.short');
if ($config->get('pattern') == 'd/m/Y - g:ia') {
$config->set('pattern', 'd/m/Y g:ia');
$config->save(TRUE);
}
}

0 comments on commit 2925d6c

Please sign in to comment.