# How should night time be calculated when it is not night during the entire flight? [duplicate]

I am B777 rated pilot and software developer. Nowadays I am working on an application about flights and this app has to calculate night time. Still I am trying to figure out how to calculate night time correctly for logging purposes. As you know night definition is easy,

Night means the time between the end of evening civil twilight and the beginning of morning civil twilight, as published in the Air Almanac, converted to local time.

But calculating a flight's night time is a little bit confusing.

1. Is this just related about being day or night at takeoff and landing airports?
2. Or whole the route should be considered if it is day or night at that time while flying?

I searched a lot but couldn't find any formula or detailed explanation about this. Just found some sites and apps can calculate night time; but interestingly every app gives different result; and still it is unclear for me that how they calculate night time.

Example:

Departure : KMIA
Destination : LTBA
Block Off Time : 03:03Z
Block On Time : 13:36Z
Block Time : 10:33


If you calculate this flight's night time via http://www.crewlogbook.com/utilities/night_calculator.php you will get:

Night Time : 01:47


I wonder how this calculation was made?

• The second part of your question(s) is how to calculate the actual night time. I am afraid this is off-topic here. You might want to remove that part of the question. Just as a hint, calculating night time is a not so trivial astronomical calculation. There is no simple formula for it. There are a number of software libraries freely available, like this one for Javascript: github.com/mourner/suncalc . Similar libraries exist for many other languages.
– bogl
Jun 29 '20 at 8:11
• About different results from different apps: all these calculations are numerical solutions of simplified models. There is no precise result. Some apps deliver a better approximation, some give a more coarse one. The authors of the libraries should document how accurate their results are. Differences of a few minutes may be considered acceptable for the sake of a fast computation.
– bogl
Jun 29 '20 at 8:21
• @bogl my purpose of calculating night time is for logging. As you may know pilots should log their flights' night times to their logbooks. So calculating that particular flight's night time becoming important. Probably because my English the question was not clear, i was not asking how can i calculate night time for a place or city, I am trying to figure out how can I can calculate flight's night time. I hope it is more clear now Jun 29 '20 at 8:47
• @h22 we have such routes that either we always fly towards sun in daylight or fleeing from sun in night around 12 hours. So you are correct sometimes I fly 13 hour and couldn't log any night time. Jun 29 '20 at 8:50
• Bahadir: You would have to calculate sunset/sunrise for virtually every point along your track. Then compare each result with the time when you passed through that point. When the times matches the sunrise or sunset time, you found a transition point and record it. The duration of night along your track is the difference between the sunrise time on the track and the sunset time on the track (modulo 24h). This is for algorithms, not for people with pen and paper.
– bogl
Jun 29 '20 at 14:47

By the time that you're operating a 777, the amount of "night" 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 & 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 "night" and the first point you weren't. Then you have "the" time that you passed from night into day.

To implement that, you'll need to calculate the EECT & 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.

• This is not a cruicial for me. But I am developing an app so for that I have to do this. Your suggestion sounds logical. I wish I could found an offical explanation about night flight time. Jun 29 '20 at 14:34
• Look out the window: If it’s black outside, log night time. If it’s gray outside, log actual IMC. Everything else is day. Jun 29 '20 at 15:16
• I have done many flights where the sun hovers around just at the horizon and will sometimes “rise” and then “set” many times during the flight. Unless you have an exact route and an exact time during the entire flight, any App calculations will not be accurate for day or night. Jun 29 '20 at 16:29
• @MikeSowsun you are right, I cannot make precise calculation without knowing actual route and timings. But this will be an approximate calculation. I will try my best. Jun 29 '20 at 19:56
• @MichaelHall it will be an app so looking out the window is not an option. Thank you anyway Jun 29 '20 at 19:56

There is the ambient light sensor on the mobile device. It can be used for picking the information about the current level of light, telling this way if there is a night or a day. All you need then is to set the timer inside your program to add the duration of the last minute to the appropriate counters (total and also either day or night). Here is a complete tutorial about the luminosity detector on the Android device and here is another about the timer.

The problem remaining is to find the place where the device does not see much of artificial light from inside the aircraft.

Many mobile devices actually use "assisted GPS" (AGPS) that picks the satellite data from Internet rather than from the satellite itself. This kind positioning does not work well in flight mode.