From 1f6663c526105ce1285e4261a00d35bfbeb0969a Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 16 Mar 2023 11:41:37 +0100 Subject: [PATCH] Remove relativeTime function --- misc/testing/NZB/nzb-reorg.php | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/misc/testing/NZB/nzb-reorg.php b/misc/testing/NZB/nzb-reorg.php index 9bb6547bd..774b0d6ac 100755 --- a/misc/testing/NZB/nzb-reorg.php +++ b/misc/testing/NZB/nzb-reorg.php @@ -7,7 +7,7 @@ use Blacklight\NZB; use Illuminate\Support\Facades\DB; if (! isset($argv[1]) || ! isset($argv[2])) { - exit("ERROR: You must supply the level you want to reorganize it to, and the source directory (You would use: 3 .../newznab/storage/nzb/ to move it to 3 levels deep)\n"); + exit("ERROR: You must supply the level you want to reorganize it to, and the source directory (You would use: 3 .../newznab/resources/nzb/ to move it to 3 levels deep)\n"); } $pdo = DB::connection()->getPdo(); @@ -20,7 +20,7 @@ $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourc $filestoprocess = []; $iFilesProcessed = $iFilesCounted = 0; -$time = time(); +$time = now()->toImmutable(); echo "\nReorganizing files to Level $newLevel from: $sourcePath This could take a while...\n"; //$consoleTools = new \ConsoleTools(); @@ -45,31 +45,4 @@ foreach ($objects as $filestoprocess => $nzbFile) { } $pdo->exec(sprintf("UPDATE settings SET value = %s WHERE setting = 'nzbsplitlevel'", $argv[1])); -$consoleTools->overWrite("Processed $iFilesProcessed nzbs in ".relativeTime($time)."\n"); - -function relativeTime($_time) -{ - $d = []; - $d[0] = [1, 'sec']; - $d[1] = [60, 'min']; - $d[2] = [3600, 'hr']; - $d[3] = [86400, 'day']; - $d[4] = [31104000, 'yr']; - - $w = []; - - $return = ''; - $now = time(); - $diff = ($now - $_time); - $secondsLeft = $diff; - - for ($i = 4; $i > -1; $i--) { - $w[$i] = (int) ($secondsLeft / $d[$i][0]); - $secondsLeft -= ($w[$i] * $d[$i][0]); - if ($w[$i] != 0) { - $return .= $w[$i].' '.$d[$i][1].(($w[$i] > 1) ? 's' : '').' '; - } - } - - return $return; -} +$consoleTools->overWrite("Processed $iFilesProcessed nzbs in ".$time->diffForHumans()."\n");