How should night time be calculated when it is not night during the entire flight?
By the time that you're operating a 777, the amount of &quot;night&quot; time in the logbook is probably of little to no concern, so getting things exactly right to the minute may not be a great worry.
I'd simply grab a location every 15 minutes, either by GPS if your app has that, or else as (time elapsed / total time) * total great circle distance, and then for that location determine if you're between EECT &amp; BMCT at that time. If so, log those minutes as night.
You could get fancier by interpolating the BMCT (for instance) between the last point you were in &quot;night&quot; and the first point you weren't. Then you have &quot;the&quot; time that you passed from night into day.
To implement that, you'll need to calculate the EECT &amp; BMCT for an given point, plus find points along the great circle route. I'd expect that algorithms are available for both of those functions, but it's not something I've ever implemented.