mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Remove relativeTime function
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user