Calculate time between sun down and 00:00 in decimal value


I have ordered the New Homey Pro, so I’m looking into replacing old / no longer maintained apps.
One functionality I use, is the Spline app to calculate the light intensity for the Toilet upstairs. From Sundown to 00:00 it goes down from 1 to 0.05 in increments.
So that is great, unfortunately Spline will not be maintained anymore.

So I’m thinking of using the Chronograph Transition functionality to calculate the light strength that is needed. But I want to have the time the transition needs to be calculated as sundown changes every day.

So Here is my question, how can I calculate the number of minutes or seconds from sundown to 00:00?

Maybe you can use a part of my script. I use the api for getting the total minutes of daylight. But when you have the time for Sunrise or Sunset you can calculate the minutes till 0:00.
Solar panels prognose with daylight minutes

This is the api call:

url = (‘'+latitude +’&lng=‘+longitude +’&date=’ + currentYear + ‘-’ + currentMonth + ‘-’ +count +‘&formatted=0’);

Just take a look at the website sunrise sunset
Website Sunrise Sunset