From e95b208af90cc386a7d8d1bcab426727cf4f0121 Mon Sep 17 00:00:00 2001 From: Minteck Date: Wed, 21 Sep 2022 22:42:33 +0200 Subject: Update time --- includes/functions.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'includes/functions.php') diff --git a/includes/functions.php b/includes/functions.php index db4a8df..1a2bf4c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -7,7 +7,7 @@ if (!function_exists("getMiniName")) { function getMiniName(string $name) { $parts = explode(" ", $name); - if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly") { + if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly" && $parts[0] !== "Windy") { if (str_contains($parts[0], "/")) { return explode("/", $parts[0])[0]; } else { @@ -19,6 +19,23 @@ if (!function_exists("getMiniName")) { } } +if (!function_exists("withCaretakersDown")) { + function withCaretakersDown(array $ordered): array { + $caretakersNo = []; + $caretakersYes = []; + + foreach ($ordered as $item) { + if ($item["_metadata"]["little"] === 2) { + $caretakersYes[] = $item; + } else { + $caretakersNo[] = $item; + } + } + + return [...$caretakersNo, ...$caretakersYes]; + } +} + if (!function_exists("getSystemMember")) { function getSystemMember(string $system, string $id) { $systemID = $system; @@ -61,7 +78,7 @@ if (!function_exists("showMembersFromList")) {
' . ($member['display_name'] ?? $member['name']) . '
-
' . ($member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '
+
' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '
'); }} } @@ -114,13 +131,13 @@ if (!function_exists("showSystem")) { $i["system"] = $id; return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id-members.json"), true), function ($i) use ($travelling) { - return !$travelling[$i['id']]['travelling']; + return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']); })), ...array_map(function ($i) use ($id) { $i["travelling"] = true; $i["system"] = ($id === "gdapd" ? "ynmuc" : "gdapd"); return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($id === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true), function ($i) use ($travelling) { - return $travelling[$i['id']]['travelling']; + return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']; }))], $id)); echo(' @@ -162,7 +179,7 @@ if (!function_exists("timeAgo")) { $time = strtotime($time); } - $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; + $periods = ["sec.", "mn.", "hr.", "d.", "wk.", "mo.", "y.", "ages"]; $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); $now = time(); @@ -182,7 +199,7 @@ if (!function_exists("timeAgo")) { $difference = round($difference); - $period = $periods[$j] . ($difference >1 ? "s" :''); + $period = $periods[$j]; return "{$difference} {$period} {$tense}"; } } -- cgit