Calculating NightFlight Hours

merc_slk

New member
Local time
Today, 14:53
Joined
Nov 24, 2009
Messages
6
Hello,
I'm strugling calculating the hours flown between Sunset and Sunrise(day +1), so called nightflight hours per leg.

An example says more :

StartTime EndTime Sunset Sunrise Total Flight Total NightFlight Legs
15:50......17:45.....18:15...05:23...01:55........00:00...............1
17:45......19:05........'..........'.......01:20........00:50...............2
19:05......23:26........'..........'.......04:21........04:21...............3

03:05......05:49........'..........'.......02:44........02:18...............9

So calculating Total Flight, even if it passes midnight no problem.
Calculating the Total NightFlight of each leg is killing me. All the time between Sunset and Sunrise is considered as Night Time.

Somebody any idea to solve this problem.

Many Tx,

Jef
 
I posted a time calculator wizard Here. This uses different periods of the day to stop/start the caclulation. This may help.

Make sure you refeence the Microsoft flat scroll bar control in your app.

Need to reference MSComCtl2.ocx via tools and references.

David
 
Last edited:
I hope I understand you correctly, and what you ask is calculating the nightflight time for each flight...

here is what you have to do. It's not the real code, but the idea of what to do.

Time1 = 0
Time2 = 0
Time3 = 0
Time4 = 0
Time5 = 0

Select case StartOfFlight
Case < Sunrise
Time1 = Sunrise - StartOfFlight
Case >= Sunrise and =< Sunset
Time1 = 0
Case > Sunset
Time1 = 24.00 - StartOfFlight ' --- start of flight to midnight
End Select

Select case EndOfFlight
Case < Sunrise
Time2 = EndOfFlight - 00.00 ' --- from midnight to end of flight
Case >= Sunrise and =< Sunset
Time2 = 0
Case > Sunset
Time2 = Sunset - StartOfFlight
End Select

If EndOfFlightDate <> StartOfFlightDate Then ' --- Over Nights
If StartOfFlight < Sunset Then
Time3 = 24.00 - Sunset ' --- from sunset to midnight
End If
If EndOfFlight > Sunrise Then
Time4 = Sunrise - 00.00 ' --- from midnight to sunrise
End If
Time5 = (24.00 - Sunset) + (Sunrise - 00.00) ' --- full night
Time 5 = (EndOfFlightDate - StartOfFlightDate - 1)*(Time5) ' --- Number of nights not including first one
End If

TotalTime = Time1 + Time2 + Time3 + Time4 + Time5



hope it help
 
Not sure, but I don't think Case statements handle And's or Or's, such as

Case >= Sunrise and =< Sunset

You will need to use If's and ElseIf's

David
 
Hello,
I changed the first idea to calculate the night flight hours. Used a lot of if's and added some more code (maybe too much) It works now. I'll test it out the comming weeks, to get rid of bugs.If any interest, I can post your changed example drake. :-)

Many thanks, never had the idea to change time to an integervalue. Much easier to compare.

Jef

Smig I had the same idea but in certain cases I get a wrong result.

Example :

Sunset 22:00 Sunrise 02:00 Start flight before noon like 11:00 and Endflight after noon 14:00. Have to check before or afternoon. Did include it in drake's example too.

Jef.

Like I said I'll post code later on, maybe you'll still have other ideas?
 
Hello,

Smig I had the same idea but in certain cases I get a wrong result.

Example :

Sunset 22:00 Sunrise 02:00 Start flight before noon like 11:00 and Endflight after noon 14:00. Have to check before or afternoon. Did include it in drake's example too.

that's why I added the last part.
 

Users who are viewing this thread

Back
Top Bottom