How to determine if custom post type showing on archive templates

You can get the post type object and check its properties. For example:

$post_type = get_post_type_object( 'books' );
if( $post_type->exclude_from_search ) {
    // The post type is not included in search results
}
if( $post_type->has_archive ) {
    // The post type has archive
}

As far I know, custom post types are not included in dates archives nor author archives if you don’t code for it (using pre_get_posts for example). I mean, those options are not available while registering a post type. So, there is no way to check it from post type object.

error code: 523