private function formatDate($when = null)
    {
        if (!$when) {
            // now
            $when = $this->formatFloatTimeToDate(microtime(true));
        } elseif (is_numeric($when)) {
            $when = $this->formatFloatTimeToDate($when);
        } elseif (!$when instanceof \DateTimeInterface) {
            throw new \InvalidArgumentException('Invalid date format. Must be a \DateTimeInterface or numeric.');
        }
        $when->setTimezone(new \DateTimeZone('UTC'));
        return $when;
    }