summaryrefslogtreecommitdiffstats
path: root/includes/class-giglogadmin-concert.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2023-01-28 17:38:32 +0100
committerHarald Eilertsen <haraldei@anduin.net>2023-01-28 17:38:32 +0100
commitc2354e7397f44998691dfe8241e49c5a65f66dcc (patch)
tree5e910758e81742b37bf0a2ef3be15eed5941dead /includes/class-giglogadmin-concert.php
parent9355261bfe664f181bd8b6c4fe23a2949e06769e (diff)
downloadgigologadmin-c2354e7397f44998691dfe8241e49c5a65f66dcc.tar.gz
gigologadmin-c2354e7397f44998691dfe8241e49c5a65f66dcc.tar.bz2
gigologadmin-c2354e7397f44998691dfe8241e49c5a65f66dcc.zip
Use DateTimeImmutable for concert date/time.
Diffstat (limited to 'includes/class-giglogadmin-concert.php')
-rw-r--r--includes/class-giglogadmin-concert.php12
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;
}
/**