mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 04:20:49 +08:00
fix carbon 3 diffIn*
This commit is contained in:
@@ -102,12 +102,11 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$whoami = executeCommand('whoami');
|
||||
$user = get_current_user();
|
||||
$uid = getmyuid();
|
||||
$uid2 = posix_getuid();
|
||||
$info = posix_getpwuid($uid2);
|
||||
dd($whoami, $user, $uid, $uid2, $info);
|
||||
$today = Carbon::today();
|
||||
$yesterday = Carbon::yesterday();
|
||||
$tomorrow = Carbon::tomorrow();
|
||||
$diff = $tomorrow->diffInDays();
|
||||
dd($today, $tomorrow, $diff);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class ClaimResource extends Resource
|
||||
,
|
||||
Tables\Columns\TextColumn::make('torrent.name')->limit(40)->label(__('label.torrent.label'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('torrent.size')->label(__('label.torrent.size'))->formatStateUsing(fn (Model $record) => mksize($record->torrent->size)),
|
||||
Tables\Columns\TextColumn::make('torrent.added')->label(__('label.torrent.ttl'))->formatStateUsing(fn (Model $record) => mkprettytime($record->torrent->added->diffInSeconds())),
|
||||
Tables\Columns\TextColumn::make('torrent.added')->label(__('label.torrent.ttl'))->formatStateUsing(fn (Model $record) => mkprettytime(abs($record->torrent->added->diffInSeconds()))),
|
||||
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at'))->dateTime(),
|
||||
Tables\Columns\TextColumn::make('last_settle_at')->label(__('label.claim.last_settle_at'))->dateTime(),
|
||||
Tables\Columns\TextColumn::make('seedTimeThisMonth')->label(__('label.claim.seed_time_this_month')),
|
||||
|
||||
@@ -73,7 +73,7 @@ class HitAndRun extends NexusModel
|
||||
return '---';
|
||||
}
|
||||
$inspectTime = HitAndRun::getConfig('inspect_time', $searchBoxId);
|
||||
$diffInSeconds = Carbon::now()->diffInSeconds($this->created_at->addHours(intval($inspectTime)));
|
||||
$diffInSeconds = Carbon::now()->diffInSeconds($this->created_at->addHours(intval($inspectTime)), true);
|
||||
return mkprettytime($diffInSeconds);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class AttendanceRepository extends BaseRepository
|
||||
//already attended today, do nothing
|
||||
$isUpdated = 0;
|
||||
} else {
|
||||
$diffDays = $today->diffInDays($added);
|
||||
$diffDays = $today->diffInDays($added, true);
|
||||
if ($diffDays == 1) {
|
||||
//yesterday do it, it's continuous
|
||||
$continuousDays = $this->getContinuousDays($attendance, Carbon::yesterday());
|
||||
@@ -292,7 +292,7 @@ class AttendanceRepository extends BaseRepository
|
||||
}
|
||||
$date = Carbon::parse($dateStr);
|
||||
$now = Carbon::now();
|
||||
if ($date->gte($now) || $now->diffInDays($date) > Attendance::MAX_RETROACTIVE_DAYS) {
|
||||
if ($date->gte($now) || $now->diffInDays($date, true) > Attendance::MAX_RETROACTIVE_DAYS) {
|
||||
throw new \LogicException(nexus_trans('attendance.target_date_can_no_be_retroactive', ['date' => $date->format('Y-m-d')]));
|
||||
}
|
||||
return NexusDB::transaction(function () use ($user, $attendance, $date) {
|
||||
|
||||
@@ -225,7 +225,7 @@ class ClaimRepository extends BaseRepository
|
||||
$uploadedCaseWhen[] = sprintf('when %s then %s', $row->id, $row->snatch->uploaded);
|
||||
} else {
|
||||
$targetStartOfMonth = $row->created_at->startOfMonth();
|
||||
if ($startOfThisMonth->diffInMonths($targetStartOfMonth) > 1) {
|
||||
if ($startOfThisMonth->diffInMonths($targetStartOfMonth, true) > 1) {
|
||||
do_log("[UNREACHED_REMOVE], uid: $uid, torrent: " . $row->torrent_id);
|
||||
$unReachedIdArr[] = $row->id;
|
||||
$unReachedTorrentIdArr[] = $row->torrent_id;
|
||||
|
||||
@@ -328,7 +328,7 @@ class ExamRepository extends BaseRepository
|
||||
|
||||
$filter = Exam::FILTER_USER_REGISTER_DAYS_RANGE;
|
||||
$filterValues = $filters[$filter] ?? [];
|
||||
$value = $user->added->diffInDays(now());
|
||||
$value = $user->added->diffInDays(now(), true);
|
||||
$begin = $filterValues[0] ?? null;
|
||||
$end = $filterValues[1] ?? null;
|
||||
if ($begin !== null && $value < $begin) {
|
||||
|
||||
@@ -300,7 +300,7 @@ class ToolRepository extends BaseRepository
|
||||
$start = Carbon::now();
|
||||
try {
|
||||
$remoteFilesystem->writeStream(basename($filename), $localFilesystem->readStream($filename));
|
||||
$speed = !(float)$start->diffInSeconds() ? 0 :filesize($filename) / (float)$start->diffInSeconds();
|
||||
$speed = !(float)abs($start->diffInSeconds()) ? 0 :filesize($filename) / (float)abs($start->diffInSeconds());
|
||||
$log = 'Elapsed time: '.$start->diffForHumans(null, true);
|
||||
$log .= ', Speed: '. number_format($speed/1024,2) . ' KB/s';
|
||||
do_log($log);
|
||||
|
||||
@@ -262,7 +262,7 @@ class TorrentRepository extends BaseRepository
|
||||
public function getPeerUploadSpeed($peer): string
|
||||
{
|
||||
$diff = $peer->uploaded - $peer->uploadoffset;
|
||||
$seconds = max(1, $peer->started->diffInSeconds($peer->last_action));
|
||||
$seconds = max(1, $peer->started->diffInSeconds($peer->last_action, true));
|
||||
return mksize($diff / $seconds) . '/s';
|
||||
}
|
||||
|
||||
@@ -270,9 +270,9 @@ class TorrentRepository extends BaseRepository
|
||||
{
|
||||
$diff = $peer->downloaded - $peer->downloadoffset;
|
||||
if ($peer->isSeeder()) {
|
||||
$seconds = max(1, $peer->started->diffInSeconds($peer->finishedat));
|
||||
$seconds = max(1, $peer->started->diffInSeconds($peer->finishedat, true));
|
||||
} else {
|
||||
$seconds = max(1, $peer->started->diffInSeconds($peer->last_action));
|
||||
$seconds = max(1, $peer->started->diffInSeconds($peer->last_action, true));
|
||||
}
|
||||
return mksize($diff / $seconds) . '/s';
|
||||
}
|
||||
@@ -550,7 +550,7 @@ class TorrentRepository extends BaseRepository
|
||||
$hasBeenDownloaded = Snatch::query()->where('torrentid', $torrent->id)->exists();
|
||||
$log = "Torrent: {$torrent->id} is in promotion, hasBeenDownloaded: $hasBeenDownloaded";
|
||||
if (!$hasBeenDownloaded) {
|
||||
$diffInSeconds = $torrent->promotion_until->diffInSeconds($torrent->added);
|
||||
$diffInSeconds = $torrent->promotion_until->diffInSeconds($torrent->added, true);
|
||||
$log .= ", addSeconds: $diffInSeconds";
|
||||
$torrentUpdate['promotion_until'] = $torrent->promotion_until->addSeconds($diffInSeconds);
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ class UserRepository extends BaseRepository
|
||||
$changeLog = $user->usernameChangeLogs()->orderBy('id', 'desc')->first();
|
||||
if ($changeLog) {
|
||||
$miniDays = Setting::get('system.change_username_min_interval_in_days', 365);
|
||||
if ($changeLog->created_at->diffInDays() <= $miniDays) {
|
||||
if (abs($changeLog->created_at->diffInDays()) <= $miniDays) {
|
||||
$msg = nexus_trans('user.change_username_lte_min_interval', ['last_change_time' => $changeLog->created_at, 'interval' => $miniDays]);
|
||||
throw new \RuntimeException($msg);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ foreach ($period as $value) {
|
||||
if ($logValue->is_retroactive) {
|
||||
$events[] = array_merge($eventBase, ['title' => $lang_attendance['retroactive_event_text'], 'display' => 'list-item']);
|
||||
}
|
||||
} elseif ($value->lte($today) && $value->diffInDays($today) <= \App\Models\Attendance::MAX_RETROACTIVE_DAYS) {
|
||||
} elseif ($value->lte($today) && $value->diffInDays($today, true) <= \App\Models\Attendance::MAX_RETROACTIVE_DAYS) {
|
||||
$events[] = array_merge($eventBase, ['groupId' => 'to_do', 'display' => 'list-item']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ foreach ($list as $row) {
|
||||
<td class='rowfollow' align='left'><a href='userdetails.php?id=" . $row->uid . "'>" . $row->user->username . "</a></td>
|
||||
<td class='rowfollow' align='left'><a href='details.php?id=" . $row->torrent_id . "'>" . $row->torrent->name . "</a></td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mksize($row->torrent->size) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mkprettytime($row->torrent->added->diffInSeconds($now)) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mkprettytime($row->torrent->added->diffInSeconds($now, true)) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . format_datetime($row->created_at) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . format_datetime($row->last_settle_at) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mkprettytime($row->snatch->seedtime - $row->seed_time_begin) . "</td>
|
||||
|
||||
@@ -30,7 +30,7 @@ $userRep = new \App\Repositories\UserRepository();
|
||||
if ($user['added'] == "0000-00-00 00:00:00" || $user['added'] == null) {
|
||||
$joindate = $lang_userdetails['text_not_available'];
|
||||
} else {
|
||||
$weeks = $userInfo->added->diffInWeeks() . nexus_trans('nexus.time_units.week');
|
||||
$weeks = abs($userInfo->added->diffInWeeks()) . nexus_trans('nexus.time_units.week');
|
||||
$joindate = $user['added']." (" . gettime($user["added"], true, false, true).", $weeks)";
|
||||
}
|
||||
$lastseen = $user["last_access"];
|
||||
|
||||
Reference in New Issue
Block a user