diff options
author | Remi Collet <remi@remirepo.net> | 2025-01-30 15:56:08 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2025-01-30 15:56:08 +0100 |
commit | 134be12f301e9e5cbd3055e7726397e588e22284 (patch) | |
tree | 900f63b2bb0d2ec51106d4af27742d7a6ba78c6d /check.php | |
parent | a4ee37e36fd0f533a7af87d179c57f1e2c744ca4 (diff) |
Diffstat (limited to 'check.php')
-rwxr-xr-x | check.php | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -169,6 +169,31 @@ function getRepoTime($uri) { } return ERR_CONTENT; } + +function delta($ref, $loc) { + $d = ($ref > $loc ? $ref - $loc : $loc - $ref); + if ($d >= 60) { + $d /= 60; + if ($d >= 60) { + $d /= 60; + if ($d >= 24) { + $d /= 24; + $unit = 'day'; + } else { + $unit = 'hour'; + } + } else { + $unit = 'minute'; + } + } else { + $unit = 'second'; + } + if ($d > 1) { + $unit .= 's'; + } + return sprintf("%s : %2d %s ago", date('r', $loc), $d, $unit); +} + if (isset($_GET['mirror']) && isset($repos[$_GET['mirror']])) { $path = $_GET['mirror']; } else { @@ -249,7 +274,7 @@ if ($ref) { printf("%50.50s : Ok\n", $mirror); exit(0); } else if ($loc) { - printf("%50.50s : %s\n", $mirror, date('r', $loc)); + printf("%50.50s : %s\n", $mirror, delta($ref, $loc)); exit(1); } else { printf("%50.50s : N/A\n", $mirror); |