mirror of
https://github.com/getformwork/formwork.git
synced 2025-01-18 05:58:20 +01:00
Replace strtotime()
with Date::toTimestamp()
This commit is contained in:
parent
d80b3dd751
commit
d84f771c5d
@ -4,6 +4,7 @@ namespace Formwork\Admin;
|
||||
|
||||
use Formwork\Admin\Utils\IPAnonymizer;
|
||||
use Formwork\Admin\Utils\Registry;
|
||||
use Formwork\Utils\Date;
|
||||
use Formwork\Utils\FileSystem;
|
||||
use Formwork\Utils\HTTPRequest;
|
||||
use Formwork\Utils\Visitor;
|
||||
@ -151,7 +152,7 @@ class Statistics
|
||||
$uniqueVisits = array_slice($uniqueVisits, -$limit, null, true);
|
||||
|
||||
$label = static function (string $day): string {
|
||||
$time = strtotime($day);
|
||||
$time = Date::toTimestamp($day, self::DATE_FORMAT);
|
||||
$month = Admin::instance()->label('date.months.short')[date('n', $time) - 1];
|
||||
$weekday = Admin::instance()->label('date.weekdays.short')[date('N', $time) % 7];
|
||||
$day = date('j', $time);
|
||||
|
@ -5,6 +5,7 @@ namespace Formwork\Admin;
|
||||
use Formwork\Admin\Utils\Registry;
|
||||
use Formwork\Core\Formwork;
|
||||
use Formwork\Parsers\JSON;
|
||||
use Formwork\Utils\Date;
|
||||
use Formwork\Utils\FileSystem;
|
||||
use Formwork\Utils\Str;
|
||||
use RuntimeException;
|
||||
@ -253,7 +254,7 @@ class Updater
|
||||
$this->release = [
|
||||
'name' => $data['name'],
|
||||
'tag' => $data['tag_name'],
|
||||
'date' => strtotime($data['published_at']),
|
||||
'date' => Date::toTimestamp($data['published_at'], DATE_ISO8601),
|
||||
'archive' => $data['zipball_url']
|
||||
];
|
||||
|
||||
|
@ -10,6 +10,7 @@ use Formwork\Parsers\YAML;
|
||||
use Formwork\Router\RouteParams;
|
||||
use Formwork\Router\Router;
|
||||
use Formwork\Traits\SingletonTrait;
|
||||
use Formwork\Utils\Date;
|
||||
use Formwork\Utils\FileSystem;
|
||||
use Formwork\Utils\Header;
|
||||
use Formwork\Utils\HTTPRequest;
|
||||
@ -336,8 +337,8 @@ final class Formwork
|
||||
return $this->site->errorPage();
|
||||
}
|
||||
if ($this->option('cache.enabled') && ($page->has('publish-date') || $page->has('unpublish-date'))) {
|
||||
if (($page->published() && !$this->site->modifiedSince((int) strtotime($page->get('publish-date'))))
|
||||
|| (!$page->published() && !$this->site->modifiedSince((int) strtotime($page->get('unpublish-date'))))) {
|
||||
if (($page->published() && !$this->site->modifiedSince(Date::toTimestamp($page->get('publish-date'))))
|
||||
|| (!$page->published() && !$this->site->modifiedSince(Date::toTimestamp($page->get('unpublish-date'))))) {
|
||||
// Clear cache if the site was not modified since the page has been published or unpublished
|
||||
$this->cache->clear();
|
||||
FileSystem::touch($this->option('content.path'));
|
||||
|
@ -7,6 +7,7 @@ use Formwork\Metadata\Metadata;
|
||||
use Formwork\Parsers\Markdown;
|
||||
use Formwork\Parsers\YAML;
|
||||
use Formwork\Template\Template;
|
||||
use Formwork\Utils\Date;
|
||||
use Formwork\Utils\FileSystem;
|
||||
use Formwork\Utils\Header;
|
||||
use Formwork\Utils\Str;
|
||||
@ -288,7 +289,7 @@ class Page extends AbstractPage
|
||||
$format = Formwork::instance()->option('date.format');
|
||||
}
|
||||
if ($this->has('publish-date')) {
|
||||
return date($format, strtotime($this->data['publish-date']));
|
||||
return date($format, Date::toTimestamp($this->data['publish-date']));
|
||||
}
|
||||
return parent::date($format);
|
||||
}
|
||||
@ -572,11 +573,11 @@ class Page extends AbstractPage
|
||||
$this->published = $this->data['published'];
|
||||
|
||||
if ($this->has('publish-date')) {
|
||||
$this->published = $this->published && strtotime($this->get('publish-date')) < time();
|
||||
$this->published = $this->published && Date::toTimestamp($this->get('publish-date')) < time();
|
||||
}
|
||||
|
||||
if ($this->has('unpublish-date')) {
|
||||
$this->published = $this->published && strtotime($this->get('unpublish-date')) > time();
|
||||
$this->published = $this->published && Date::toTimestamp($this->get('unpublish-date')) > time();
|
||||
}
|
||||
|
||||
$this->routable = $this->data['routable'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user