How to create a permission with logic in Drupal 8

I must authorize grammatically to allow users to view the content preview page (/ admin / content) only during business hours (9:00 am to 5:00 pm).

Drupal Core comes with the "Go to Content Page" permission; but I need to "Access the content presentation page during working hours".

I know how to create a permission and how to check that the user has permission. What I do not understand is how to assign some logic to an authorization itself (for example, "in business hours").

I can do it in mymodule.permissions.yml:

access the overview of the content during business hours:
Title: "Go to the presentation page of content in business hours"
restrict access: TRUE

I can verify that the user has the authorization as follows:

 Drupal :: currentUser () -> hasPermission ("preview of access contents during business hours")

How can I make the authorization? TRUE only during office hours?

How can I check permission only when users visit the content preview page?

I can foresee several cases of use requiring a logical implementation in the authorization itself. For example. Allow / restrict access to certain pages depending on whether the environment is Dev or Prod. Allow / restrict access based on the value of certain fields.