mirror of
https://github.com/standardebooks/web.git
synced 2025-07-08 15:50:29 -04:00
Convert use of gmdate() to DateTime
This commit is contained in:
parent
854fb2c816
commit
1237a65bc8
4 changed files with 17 additions and 11 deletions
|
@ -1,9 +1,12 @@
|
|||
<?
|
||||
// Auto-included by Composer in composer.json to satisfy PHPStan
|
||||
use Safe\DateTime;
|
||||
use function Safe\define;
|
||||
use function Safe\gmdate;
|
||||
use function Safe\strtotime;
|
||||
|
||||
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||
$nowPd = new DateTime('now', new DateTimeZone('America/Juneau')); // Latest continental US time zone
|
||||
|
||||
const SITE_STATUS_LIVE = 'live';
|
||||
const SITE_STATUS_DEV = 'dev';
|
||||
|
||||
|
@ -110,10 +113,10 @@ const ZOHO_WEBHOOK_LOG_FILE_PATH = '/var/log/local/webhooks-zoho.log'; // Must b
|
|||
const DONATIONS_LOG_FILE_PATH = '/var/log/local/donations.log'; // Must be writable by `www-data` Unix user.
|
||||
const ARTWORK_UPLOADS_LOG_FILE_PATH = '/var/log/local/artwork-uploads.log'; // Must be writable by `www-data` Unix user.
|
||||
|
||||
define('PD_YEAR', intval(gmdate('Y')) - 96);
|
||||
define('PD_YEAR', intval($nowPd->format('Y')) - 96);
|
||||
define('PD_STRING', 'January 1, ' . (PD_YEAR + 1));
|
||||
|
||||
define('DONATION_HOLIDAY_ALERT_ON', time() > strtotime('November 15, ' . gmdate('Y')) || time() < strtotime('January 7, ' . gmdate('Y')));
|
||||
define('DONATION_HOLIDAY_ALERT_ON', $now > new DateTime('November 15, ' . $now->format('Y'), new DateTimeZone('UTC')) || $now < new DateTime('January 7, ' . $now->add(new DateInterval('P1Y'))->format('Y'), new DateTimeZone('UTC')));
|
||||
define('DONATION_ALERT_ON', DONATION_HOLIDAY_ALERT_ON || rand(1, 4) == 2);
|
||||
|
||||
// Controls the progress bar donation dialog
|
||||
|
|
|
@ -5,7 +5,6 @@ use function Safe\exec;
|
|||
use function Safe\filemtime;
|
||||
use function Safe\filesize;
|
||||
use function Safe\glob;
|
||||
use function Safe\gmdate;
|
||||
use function Safe\ksort;
|
||||
use function Safe\preg_replace;
|
||||
use function Safe\shell_exec;
|
||||
|
@ -342,6 +341,7 @@ class Library{
|
|||
|
||||
private static function FillBulkDownloadObject(string $dir, string $downloadType, string $urlRoot): stdClass{
|
||||
$obj = new stdClass();
|
||||
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
// The count of ebooks in each file is stored as a filesystem attribute
|
||||
$obj->EbookCount = exec('attr -g se-ebook-count ' . escapeshellarg($dir)) ?: null;
|
||||
|
@ -392,7 +392,7 @@ class Library{
|
|||
$obj->UpdatedString = $obj->Updated->format('M j');
|
||||
// Add a period to the abbreviated month, but not if it's May (the only 3-letter month)
|
||||
$obj->UpdatedString = preg_replace('/^(.+?)(?<!May) /', '\1. ', $obj->UpdatedString);
|
||||
if($obj->Updated->format('Y') != gmdate('Y')){
|
||||
if($obj->Updated->format('Y') != $now->format('Y')){
|
||||
$obj->UpdatedString = $obj->Updated->format('M j, Y');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?
|
||||
use Safe\DateTime;
|
||||
use function Safe\fopen;
|
||||
use function Safe\fwrite;
|
||||
use function Safe\fclose;
|
||||
use function Safe\error_log;
|
||||
use function Safe\gmdate;
|
||||
use function Safe\substr;
|
||||
|
||||
class Log{
|
||||
|
@ -34,7 +34,9 @@ class Log{
|
|||
return;
|
||||
}
|
||||
|
||||
fwrite($fp, gmdate('Y-m-d H:i:s') . "\t" . $this->RequestId . "\t" . $text . "\n");
|
||||
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
fwrite($fp, $now->format('Y-m-d H:i:s') . "\t" . $this->RequestId . "\t" . $text . "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?
|
||||
use function Safe\gmdate;
|
||||
use Safe\DateTime;
|
||||
use function Safe\session_unset;
|
||||
|
||||
session_start();
|
||||
|
@ -8,6 +8,7 @@ $created = HttpInput::Bool(SESSION, 'artwork-created', false);
|
|||
$exception = $_SESSION['exception'] ?? null;
|
||||
/** @var Artwork $artwork */
|
||||
$artwork = $_SESSION['artwork'] ?? null;
|
||||
$now = new DateTime('now', new DateTimeZone('America/Juneau')); // Latest continental US time zone
|
||||
|
||||
try{
|
||||
if($GLOBALS['User'] === null){
|
||||
|
@ -93,7 +94,7 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
type="number"
|
||||
name="artist-year-of-death"
|
||||
min="1"
|
||||
max="<?= gmdate('Y') ?>"
|
||||
max="<?= $now->format('Y') ?>"
|
||||
value="<?= $artwork->Artist->DeathYear ?>"
|
||||
/>
|
||||
</label>
|
||||
|
@ -112,7 +113,7 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
type="number"
|
||||
name="artwork-year"
|
||||
min="1"
|
||||
max="<?= gmdate('Y') ?>"
|
||||
max="<?= $now->format('Y') ?>"
|
||||
value="<?= $artwork->CompletedYear ?>"
|
||||
/>
|
||||
</label>
|
||||
|
@ -169,7 +170,7 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
type="number"
|
||||
name="artwork-publication-year"
|
||||
min="1"
|
||||
max="<?= gmdate('Y') ?>"
|
||||
max="<?= $now->format('Y') ?>"
|
||||
value="<?= $artwork->PublicationYear ?>"
|
||||
/>
|
||||
</label>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue