format("G"); } public function minutes(): int { return (int) $this->format("i"); } public function since_midnight_str(): string { $hours = $this->hours(); $minutes = $this->minutes(); // Show minutes if we're not into the first hour yet if ($hours < 1) { return $minutes . " minute" . to_plural($minutes); } // Round up to the nearest hour return ($minutes < 45 ? $hours : $hours + 1) . " hour" . to_plural($hours); } }; $coffee = new class extends API { const THRESHOLDS = [ [-10, "a lot less than"], [-5, "a bit less than"], [0, "average"], [5, "a bit more than"], [10, "a lot more than"] ]; private readonly int $now; private readonly Response $resp; public function __construct() { parent::__construct(); $this->now = time(); $this->resp = $this->call(Endpoints::PLAYGROUND_COFFEE->value)->get(); } private function get_until_timestamp(int $offset = 0): array { return array_filter($this->resp->json(), fn(int $timestamp): int => $timestamp > $offset); } private function get_average_month(): int { $days = [0]; foreach ($this->get_until_timestamp(2592000) as $timestamp) { // Append new value for next 24 hours if ($timestamp % 86400 === 0) { $days[] = 0; } $days[count($days) - 1]++; } // Count the average for each day return array_sum($days) / count($days); } // Return the number of cups within the last 24 hours public function get_today(): int { return $this->resp->ok ? count($this->get_until_timestamp(86400)) : 0; } public function get_average_month_str(): string { $diff = $this->get_today() - $this->get_average_month(); // Check diff of today against monthyl average thresholds foreach (self::THRESHOLDS as $threshold) { [$limit, $msg] = $threshold; // Bail out if diff is less than threshold limit if ($diff < $limit) { return $msg; } } // Return last entry if diff is more than last threshold limit return self::THRESHOLDS[count(self::THRESHOLDS) - 1][1]; } }; ?>
$char): ?> " style="animation-delay:ms">

I'm so bored.

Don't like the way my website looks? These oficially very Super Secret Settings will give you something else to look at!

">

What else.. I've had get_today() ?> cupget_today()) ?> of coffee today!

That's get_average_month_str() ?> the daily average for me (last 30 days). Here I'm counting how many ~300ml cups of coffee I've had since midnight for my timezone , that was since_midnight_str() ?> ago.

How much coffee is enough coffee? value ?>">Click here to see my answer!! (NOT CLICKBAIT). Each array value is a UNIX timestamp that represents a single cup of coffee.