public function updateWorkout(Workout $workout)
    {
        if (!$workout->getId()) {
            throw new EndomondoApiOldException('You cannot edit workout without knowing its ID.');
        }

        $utc = new \DateTimeZone('UTC');
        $timeFormat = 'Y-m-d H:i:s \U\T\C';

        $data = [
            'duration' => $workout->getDuration(),
            'sport' => $workout->getTypeId(),
            'distance' => $workout->getDistance(),
            'start_time' => $workout->getStart()->setTimezone($utc)->format($timeFormat),
            'end_time' => $workout->getEnd()->setTimezone($utc)->format($timeFormat),
            'extendedResponse' => 'true',
            'gzip' => 'true',
        ];

        if ($workout->getCalories() !== null) {
            $data['calories'] = $workout->getCalories();
        }

        if ($workout->getNotes() !== null) {
            $data['notes'] = $workout->getNotes();
        }

        if ($workout->getMapPrivacy() !== null) {
            $data['privacy_map'] = $workout->getMapPrivacy();
        }

        if ($workout->getWorkoutPrivacy() !== null) {
            $data['privacy_workout'] = $workout->getWorkoutPrivacy();
        }

        $this->request(self::UPDATE_WORKOUT_ENDPOINT, [
            'workoutId' => $workout->getId(),
            'userId' => $this->getUserId(),
            'gzip' => 'true',
        ], json_encode($data));

        return $this->getWorkout($workout->getId());
    }