mirror of
https://github.com/standardebooks/web.git
synced 2025-07-18 20:36:38 -04:00
Add DateTimeFormat enum
This commit is contained in:
parent
be5574eaec
commit
c35c47b793
18 changed files with 38 additions and 26 deletions
|
@ -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;
|
||||
|
|
12
lib/Enums/DateTimeFormat.php
Normal file
12
lib/Enums/DateTimeFormat.php
Normal file
|
@ -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';
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue