| | } |
| | |
| | +function time_elapsed_string($timestamp) { |
| | + if (!$timestamp) return 'never'; |
| | + |
| | + $diff = time() - $timestamp; |
| | + if ($diff < 5) return 'just now'; |
| | + |
| | + $tokens = [ |
| | + 31536000 => 'year', |
| | + 2592000 => 'month', |
| | + 604800 => 'week', |
| | + 86400 => 'day', |
| | + 3600 => 'hour', |
| | + 60 => 'minute', |
| | + 1 => 'second' |
| | + ]; |
| | + |
| | + foreach ($tokens as $unit => $text) { |
| | + if ($diff < $unit) continue; |
| | + $numberOfUnits = floor($diff / $unit); |
| | + return $numberOfUnits . ' ' . $text . (($numberOfUnits > 1) ? 's' : '') . ' ago'; |
| | + } |
| | + return 'just now'; |
| | +} |
| | + |
| | function detectType($data) { |
| | if (strlen($data) < 25) return 'blob'; |
 |
| | |
| | $repoGit->history('HEAD', 1, function($commit) { |
| | - echo '<p style="margin-top: 8px; color: #58a6ff;">' . substr($commit->sha, 0, 7) . ' - ' . htmlspecialchars(substr(explode("\n", $commit->message)[0], 0, 50)) . '</p>'; |
| | + // CHANGED: Display relative time instead of SHA/Message |
| | + echo '<p style="margin-top: 8px; color: #58a6ff;">' . time_elapsed_string($commit->date) . '</p>'; |
| | }); |
| | |