diff --git a/lib/AtomFeed.php b/lib/AtomFeed.php index 5a33dfd3..f3aa0887 100644 --- a/lib/AtomFeed.php +++ b/lib/AtomFeed.php @@ -54,11 +54,11 @@ class AtomFeed extends Feed{ foreach($this->Entries as $entry){ $obj = new StdClass(); if($entry instanceof Ebook){ - $obj->Updated = $entry->EbookUpdated->format('Y-m-d\TH:i:s\Z'); + $obj->Updated = $entry->EbookUpdated->format(Enums\DateTimeFormat::Iso->value); $obj->Id = SITE_URL . $entry->Url; } else{ - $obj->Updated = $entry->Updated !== null ? $entry->Updated->format('Y-m-d\TH:i:s\Z') : ''; + $obj->Updated = $entry->Updated !== null ? $entry->Updated->format(Enums\DateTimeFormat::Iso->value) : ''; $obj->Id = $entry->Id; } $currentEntries[] = $obj; diff --git a/lib/Enums/DateTimeFormat.php b/lib/Enums/DateTimeFormat.php new file mode 100644 index 00000000..5312e3e2 --- /dev/null +++ b/lib/Enums/DateTimeFormat.php @@ -0,0 +1,12 @@ + +namespace Enums; + +enum DateTimeFormat: string{ + case Sql = 'Y-m-d H:i:s'; // `2022-01-05 23:42:12` + case Iso = 'Y-m-d\TH:i:s\Z'; // `2022-01-05T23:42:12Z` + case FullDateTime = 'F j, Y g:i a'; // `January 5, 2022 2:04 pm` + case Ical = 'Ymd\THis\Z'; //20220105T234212Z + case Html = 'Y-m-d\TH:i:s'; // `2022-01-05T23:42:12` + case Rss = 'r'; // `D, d M Y H:i:s` + case UnixTimestamp = 'U'; +} diff --git a/lib/Session.php b/lib/Session.php index 853115b1..3ca8a9bc 100644 --- a/lib/Session.php +++ b/lib/Session.php @@ -98,7 +98,7 @@ class Session{ public static function SetSessionCookie(string $sessionId): void{ /** @throws void */ - setcookie('sessionid', $sessionId, ['expires' => intval((new DateTimeImmutable('+1 week'))->format('U')), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks + setcookie('sessionid', $sessionId, ['expires' => intval((new DateTimeImmutable('+1 week'))->format(Enums\DateTimeFormat::UnixTimestamp->value)), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks } /** diff --git a/templates/AtomFeed.php b/templates/AtomFeed.php index 7cfed045..b34f9c6f 100644 --- a/templates/AtomFeed.php +++ b/templates/AtomFeed.php @@ -21,7 +21,7 @@ print("\n");
= $poll->Description ?>
if($poll->IsActive()){ ?> if($poll->End !== null){ ?> -This poll closes on = $poll->End->format('F j, Y g:i a') ?>.
+This poll closes on = $poll->End->format(Enums\DateTimeFormat::FullDateTime->value) ?>.
} ?> if(!$canVote){ ?>You’ve already voted in this poll.
@@ -48,9 +48,9 @@ catch(Exceptions\AppException){ }else{ ?> if($poll->Start !== null && $poll->Start > NOW){ ?> -This poll opens on = $poll->Start->format('F j, Y g:i a') ?>.
+This poll opens on = $poll->Start->format(Enums\DateTimeFormat::FullDateTime->value) ?>.
}else{ ?> -This poll closed on = $poll->End->format('F j, Y g:i a') ?>.
+This poll closed on = $poll->End->format(Enums\DateTimeFormat::FullDateTime->value) ?>.
} ?> } ?> diff --git a/www/polls/votes/get.php b/www/polls/votes/get.php index 283201a3..acb6e769 100644 --- a/www/polls/votes/get.php +++ b/www/polls/votes/get.php @@ -26,7 +26,7 @@ catch(Exceptions\AppException){ if($created){ ?>Thank you for voting in the = Formatter::EscapeHtml($vote->PollItem->Poll->Name) ?> poll.
}else{ ?> -Your vote in the = Formatter::EscapeHtml($vote->PollItem->Poll->Name) ?> poll was submitted on = $vote->Created->format('F j, Y g:i a') ?>.
+Your vote in the = Formatter::EscapeHtml($vote->PollItem->Poll->Name) ?> poll was submitted on = $vote->Created->format(Enums\DateTimeFormat::FullDateTime->value) ?>.
} ?> diff --git a/www/polls/votes/index.php b/www/polls/votes/index.php index 3e3ebee8..58b5c15b 100644 --- a/www/polls/votes/index.php +++ b/www/polls/votes/index.php @@ -15,10 +15,10 @@ catch(Exceptions\AppException){Total votes: = number_format($poll->VoteCount) ?>
if($poll->IsActive()){ ?> if($poll->End !== null){ ?> -This poll closes on = $poll->End->format('F j, Y g:i a') ?>.
+This poll closes on = $poll->End->format(Enums\DateTimeFormat::FullDateTime->value) ?>.
} ?> }elseif($poll->End !== null){ ?> -This poll closed on = $poll->End->format('F j, Y g:i a') ?>.
+This poll closed on = $poll->End->format(Enums\DateTimeFormat::FullDateTime->value) ?>.
} ?>