<?php
/**
 * @var $data array
 */

use auctionforge\inc\controllers\Settings;
use auctionforge\inc\helpers\SettingsHelper;

$auctionDay = $data['auctionDay'];
$customDateFormat = SettingsHelper::getOption('custom_format_display_time', '');

if (!empty($auctionDay->unknownExactDate)) {
    $dateTime = $auctionDay->date;
} else {
    $dateTime = $auctionDay->date . 'T' . $auctionDay->time;
}
try {
    $newDateTime = new DateTime($dateTime);
} catch (Exception $e) {
    $newDateTime = new DateTime();
}
$timeZoneLabel = SettingsHelper::getOption('time_zone_label', '');
if ($timeZoneLabel != '') {
    $timeZoneLabel = "(" . $timeZoneLabel . ")";
}
$dateTime = SettingsHelper::dateTimeFormat($dateTime);
?>
<p class="bp-auction-start-date"
   data-custom-format="<?= $customDateFormat ?>"
   data-custom-format-time="<?= date_i18n($customDateFormat, $newDateTime->getTimestamp()) . " " . $timeZoneLabel ?>"
   data-time="<?= $dateTime ?>"
   data-unknown-exact-date="<?= $auctionDay->unknownExactDate ?>"
   data-unknown-date="<?= date_i18n("F Y", strtotime($dateTime)) ?>"></p>