static function atTime($now, callable $callback)
    {
        // store time if already overridden
        if (Clock::isOverridden()) {
            $previousOverride = Clock::microtime();
        } else {
            $previousOverride = null;
        }

        try {
            // override time
            Clock::override($now);

            // invoke callback
            return $callback();
        } finally {
            // restore previous state
            if ($previousOverride === null) {
                // no previous override - resume
                Clock::resume();
            } else {
                // restore previous override
                Clock::override($previousOverride);
            }
        }
    }