This one involves a lot of TIME logic
DESCRIPTION:
Here in Brazil pilots can only work a certain amount a time depending on how many pilots are in the crew.
This amount of time is calculated from the time the pilot checks in to the time the pilot shut down the engine.
A 2 Pilot crew may work 10:30hrs (10 hours and 30 minutes)
A 3 Pilot Crew may work 13:30hrs
A 4 Pilot crew may work 19:30hrs
BUT
Only For a 2 Pilot crew the night shift ( from 18:01 to 05:59) cannot exceed 9:30hrs (9 hours 30 minutes)
Another thing, for shifts that start during the day and finish at night, or, start at night and finish at daytime,(Called mixed shift)
The night time should be considered having 52 minutes and 30 seconds.
Confusing?
Thats why we have 3 tables that are "pre" calculated with a 15 minutes interval so we dont have to make this calculation everytime.
This tables are attached.
Lets have a practical example:
I Tell you how I do it, dont know if its the best way.
A 2 Pilot crew Checked In at 15:00Hr, how much can this pilots fly?
From 15:00 to 18:00 (daytime), we consider 1:00 = 1:00 so 3 hours
Starting 18:00, this 2 pilots can fly 7:30 more (10:30 - 3:00 = 7:30)
So I convert everything to seconds:
1 hour = 3600 seconds
52m30sec = 3150 seconds
To find the magic number we divide 3600/3150 = 1,142857
7:30hrs = 27000 seconds
27000/1,142857 = 23625 seconds
23625 seconds = 6 hours 33 minutes 45 seconds
6 hours 33 minutes 45 seconds + 3 hours(daytime) = 9 hours 33 minutes 45 seconds
So starting at 15:00 a pilot may work 9 hours 33 minutes 45 seconds
So a 2 pilot crew can work until 00:33
If the same crew stars at 18:00, we justa have to add 9:30, because its a entire night shift, its not a mixed shift, so the crew can work until 18:00+9:30=03:30
Just remembering that this does not aply to the 3 and 4 pilots crew
GOAL:
Have a HTML page that I can put on a server, and trough javascript or JQuery, do this calculation for me.
So When I enter the check in Time it calculates the 2, 3 and 4 pilots limit working time.
Just to clarified the Message before, 1:00 at day should be considered 52min and 30sec for night calculation.
And the 3 and 4 pilot crew does not have the 9:30 hour night time limitation
On the table image attached APRES=CHECKIN and CORTE=SHUTDOWN ENG
Please ask all the questions you need. BEFORE ACCEPTING THE PROJECT
Can be done using jQuery or basic Javascript. It is a bit confusing but I understand the logic required and have an algorithm in mind on how to implement the same. Do you have a link to the HTML form that you have created so I can take a look? Thanks