Skip to content

Commit

Permalink
Merge pull request #617 from carstingaxion/feature/use-date-time-form…
Browse files Browse the repository at this point in the history
…at-defaults

Use date & time format defaults from options
  • Loading branch information
mauteri authored Mar 20, 2024
2 parents ceff32e + 436dc99 commit 70cdbf9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/core/classes/settings/class-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected function get_sections(): array {
'type' => 'text',
'size' => 'regular',
'options' => array(
'default' => 'l, F j, Y',
'default' => get_option( 'date_format', 'l, F j, Y' ),
),
),
),
Expand All @@ -184,7 +184,7 @@ protected function get_sections(): array {
'type' => 'text',
'size' => 'regular',
'options' => array(
'default' => 'g:i A',
'default' => get_option( 'time_format', 'g:i A' ),
),
),
),
Expand Down
4 changes: 4 additions & 0 deletions test/unit/php/includes/core/classes/class-test-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public function data_get_display_datetime(): array {
* @return void
*/
public function test_get_display_datetime( array $params, string $expects ): void {

update_option( 'date_format', 'l, F j, Y' );
update_option( 'time_format', 'g:i A' );

$post = $this->mock->post(
array(
'post_title' => 'Unit Test Event',
Expand Down
4 changes: 4 additions & 0 deletions test/unit/php/includes/core/classes/class-test-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ public function test_validate_timezone(): void {
* @return void
*/
public function test_update_datetime(): void {

update_option( 'date_format', 'l, F j, Y' );
update_option( 'time_format', 'g:i A' );

$instance = Rest_Api::get_instance();

$request = new WP_REST_Request( 'POST' );
Expand Down

0 comments on commit 70cdbf9

Please sign in to comment.