import time


def create_version(vms, version_name=None):
    """Create a new branch version

    Args:
      vms (arcgis.features._version.VersionManager): VersionManager object
      version_name (str): (Optional) name of the version to be created
    Returns:
      The fully qualified version name (`owner.version_name`) string
    """
    try:
        timestamp = int(time.time())
        if not version_name:
            # VersionManagementServer - Create a new version
            version_name = "api-{}".format(timestamp)
        else:
            version_name = f"{version_name}_{timestamp}"
        return vms.create(version_name)["versionInfo"]["versionName"]
    except Exception as ex:
        print(ex)
        return None