diff options
Diffstat (limited to 'includes/class-giglogadmin-concert.php')
-rw-r--r-- | includes/class-giglogadmin-concert.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/includes/class-giglogadmin-concert.php b/includes/class-giglogadmin-concert.php index 6c7c4da..f669c03 100644 --- a/includes/class-giglogadmin-concert.php +++ b/includes/class-giglogadmin-concert.php @@ -21,7 +21,7 @@ if ( ! class_exists( 'GiglogAdmin_Concert' ) ) { private ?int $id; private ?string $cname; private ?GiglogAdmin_Venue $venue; - private ?string $cdate; + private DateTimeImmutable $cdate; private ?string $tickets; private ?string $eventlink; private ?int $status; @@ -50,7 +50,7 @@ if ( ! class_exists( 'GiglogAdmin_Concert' ) ) { public function __construct( object $attrs ) { $this->id = isset( $attrs->id ) ? $attrs->id : null; $this->cname = isset( $attrs->wpgconcert_name ) ? $attrs->wpgconcert_name : null; - $this->cdate = isset( $attrs->wpgconcert_date ) ? $attrs->wpgconcert_date : null; + $this->cdate = new DateTimeImmutable( $attrs->wpgconcert_date ?? 'now' ); $this->tickets = isset( $attrs->wpgconcert_tickets ) ? $attrs->wpgconcert_tickets : null; $this->eventlink = isset( $attrs->wpgconcert_event ) ? $attrs->wpgconcert_event : null; $this->status = isset( $attrs->wpgconcert_status ) ? $attrs->wpgconcert_status : 0; @@ -141,7 +141,7 @@ if ( ! class_exists( 'GiglogAdmin_Concert' ) ) { } if ( isset( $attrs->wpgconcert_date ) && $attrs->wpgconcert_date != $this->cdate ) { - $this->cdate = $attrs->wpgconcert_date; + $this->cdate = new DateTimeImmutable( $attrs->wpgconcert_date ); $need_update = true; } @@ -305,7 +305,7 @@ if ( ! class_exists( 'GiglogAdmin_Concert' ) ) { $columns = array( 'wpgconcert_name' => $this->cname, 'venue' => $this->venue->id(), - 'wpgconcert_date' => $this->cdate, + 'wpgconcert_date' => $this->cdate->format( 'c' ), 'wpgconcert_tickets' => $this->tickets, 'wpgconcert_event' => $this->eventlink, 'wpgconcert_status' => $this->status, @@ -349,8 +349,8 @@ if ( ! class_exists( 'GiglogAdmin_Concert' ) ) { /** * Return the date of the concert. */ - public function cdate() { - return $this->cdate ? $this->cdate : ''; + public function cdate() : DateTimeImmutable { + return $this->cdate; } /** |