Address PHPStan warnings in 'classes/timehelper.php'.
This commit is contained in:
parent
03495c11ed
commit
f704d25ab1
|
@ -299,7 +299,7 @@ class Feeds extends Handler_Protected {
|
||||||
$this->_mark_timestamp(" enclosures");
|
$this->_mark_timestamp(" enclosures");
|
||||||
|
|
||||||
$line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true);
|
$line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true);
|
||||||
$line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, false, false, true);
|
$line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, null, false, true);
|
||||||
|
|
||||||
$line['imported'] = T_sprintf("Imported at %s",
|
$line['imported'] = T_sprintf("Imported at %s",
|
||||||
TimeHelper::make_local_datetime($line["date_entered"], false));
|
TimeHelper::make_local_datetime($line["date_entered"], false));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
class TimeHelper {
|
class TimeHelper {
|
||||||
|
|
||||||
static function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) {
|
static function smart_date_time(int $timestamp, int $tz_offset = 0, int $owner_uid = null, bool $eta_min = false): string {
|
||||||
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
|
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
|
||||||
|
|
||||||
if ($eta_min && time() + $tz_offset - $timestamp < 3600) {
|
if ($eta_min && time() + $tz_offset - $timestamp < 3600) {
|
||||||
|
@ -21,8 +21,8 @@ class TimeHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function make_local_datetime($timestamp, $long, $owner_uid = false,
|
static function make_local_datetime(string $timestamp, bool $long, int $owner_uid = null,
|
||||||
$no_smart_dt = false, $eta_min = false) {
|
bool $no_smart_dt = false, bool $eta_min = false): string {
|
||||||
|
|
||||||
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
|
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
|
||||||
if (!$timestamp) $timestamp = '1970-01-01 0:00';
|
if (!$timestamp) $timestamp = '1970-01-01 0:00';
|
||||||
|
@ -67,7 +67,7 @@ class TimeHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function convert_timestamp($timestamp, $source_tz, $dest_tz) {
|
static function convert_timestamp(int $timestamp, string $source_tz, string $dest_tz): int {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$source_tz = new DateTimeZone($source_tz);
|
$source_tz = new DateTimeZone($source_tz);
|
||||||
|
|
|
@ -213,12 +213,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function is @deprecated by TimeHelper::smart_date_time() */
|
/** function is @deprecated by TimeHelper::smart_date_time() */
|
||||||
function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) {
|
function smart_date_time(int $timestamp, int $tz_offset = 0, int $owner_uid = null, bool $eta_min = false): string {
|
||||||
return TimeHelper::smart_date_time($timestamp, $tz_offset, $owner_uid, $eta_min);
|
return TimeHelper::smart_date_time($timestamp, $tz_offset, $owner_uid, $eta_min);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function is @deprecated by TimeHelper::make_local_datetime() */
|
/** function is @deprecated by TimeHelper::make_local_datetime() */
|
||||||
function make_local_datetime($timestamp, $long, $owner_uid = false, $no_smart_dt = false, $eta_min = false) {
|
function make_local_datetime(string $timestamp, bool $long, int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string {
|
||||||
return TimeHelper::make_local_datetime($timestamp, $long, $owner_uid, $no_smart_dt, $eta_min);
|
return TimeHelper::make_local_datetime($timestamp, $long, $owner_uid, $no_smart_dt, $eta_min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue