public function convertPackageToArray(PackageInterface $package, PackageInterface $upgrade = null)
    {
        $name = $package->getPrettyName();
        $data = new JsonArray([
            'name'       => $name,
            'version'    => $this->convertPackageVersion($package),
            'constraint' => $this->getConstraint($name),
            'type'       => $package->getType(),
            'locked'     => $this->isLocked($name),
        ]);

        if (null !== ($releaseDate = $package->getReleaseDate())) {
            $data->set('time', $releaseDate->format(\DateTime::ATOM));
        }

        if (null !== $upgrade) {
            $data->set('upgrade_version', $upgrade->getPrettyVersion());
            if (null !== ($upgradeReleaseDate = $upgrade->getReleaseDate())) {
                $data->set('upgrade_time', $upgradeReleaseDate->format(\DateTime::ATOM));
            }
        }

        if ($package instanceof CompletePackageInterface) {
            $this->convertCompletePackage($package, $data);
        }

        return $data;
    }