As I said above, this is how the DA is calculated. There is already a component for post-processing annual daylight simulation results. See the code and modify it for your purpose. For every hour that there is not enough daylight you should set the lighting schedule to 1. Here is the code: