protected function convert($data)
    {
        if ($data instanceof DateTime) {
            $data = clone $data; // don't change to original value
            return $data->setTimezone($this->timezone)->format('Y-m-d\TG:i:s\Z');
        }

        if (is_object($data) && !method_exists($data, '__toString')) {
            return null; // can't convert object to a string.
        }

        if (is_array($data)) {
            return null; // can't convert a array to a string.
        }

        if (is_bool($data)) {
            return $data ? '1' : '0'; // would otherwise be empty if converted to a string
        }

        return $data !== null ? (string)$data : null;
    }