View Full Version : Flights that Cross Midnight
I'm not sure where to post this, so please re-direct me if there is a
better place.
I have a project where I have to determine the correct GMT time offset
for the arrive staton of a flight. I'm doing this for a company that
deals with airline carriers all over the world. All that I have to
work with are the depart station, depart station local time, arrive
station, arrive station local time, and the flight effective date
(which is the date the flight departs). The GMT data that I work with
is in local times per the station.
Some thoughts or questions to consider . . .
In order to get the correct GMT offset for the arrive station, I have
to know the correct date to use. This usually is not a problem,
except it can be if a flight crosses over midnight (meaning it will be
the next day at the arrival station) and the flight departed the day
before time change date.
Their current function always gets the GMT based on the effective date
of the flight. This is fine for 99% of the time. When a flight
crosses midnight and it's around time change dates, the effective date
of the flight might need to have a day added to it if the flight
crossed over midnight.
Any input or direction would be greatly appreciated.
Teacherjh
May 6th 04, 12:53 AM
>>
In order to get the correct GMT offset for the arrive station, I have
to know the correct date to use.
<<
Just let your times go past 24:00 and less than 00:00. Then do a check, and
add or subtract a day based on the result. For example, starting with 23:00,
five hours of flight, and a +2 hour offset, you end up with 30:00 on (say)
Tuesday. Then you check to see if the time is <00:00 or >=24:00. Since it's
>+24:00, add a day and take away 24:00. So now we have 06:00 Wednesday.
Same idea, if you start out at 03:00 Friday, a two hour flight, and a seven
hour offset (the other way) (in the Space Shuttle, presumably!), you end up
with -06:00 (six hours below zero). We check to see if this is <00:00, and if
so, ADD 24:00 and subtract a day. We h ave 18:00 Thursday.
Limit checks like this are common for all date and time conversions (in fact,
any modulo arithmetic with carry). You'll need to check to see if the date
goes past Sunday (day 7) so it can cycle "back" to Monday (day 1), see if you
passed 31 or 30 or 29 or 28 (depending on month and year) so it can cycle back
to the first of Next Month, see if we passed December, etc.
Jose
--
(for Email, make the obvious changes in my address)
Peter Duniho
May 6th 04, 01:44 AM
"ydm9" > wrote in message
om...
> [...]
> Their current function always gets the GMT based on the effective date
> of the flight. This is fine for 99% of the time. When a flight
> crosses midnight and it's around time change dates, the effective date
> of the flight might need to have a day added to it if the flight
> crossed over midnight.
>
> Any input or direction would be greatly appreciated.
I think your employers should hire a better programmer.
If you think the problem you're working on now is hard, wait until you have
to deal with a flight that crosses the International Date Line. I'm
guessing your head will explode.
Pete
Richard Hertz
May 6th 04, 01:54 AM
"Peter Duniho" > wrote in message
...
> "ydm9" > wrote in message
> om...
> > [...]
> > Their current function always gets the GMT based on the effective date
> > of the flight. This is fine for 99% of the time. When a flight
> > crosses midnight and it's around time change dates, the effective date
> > of the flight might need to have a day added to it if the flight
> > crossed over midnight.
> >
> > Any input or direction would be greatly appreciated.
>
> I think your employers should hire a better programmer.
>
> If you think the problem you're working on now is hard, wait until you
have
> to deal with a flight that crosses the International Date Line. I'm
> guessing your head will explode.
>
> Pete
>
Nice - I was thinking the same thing.
>
David Brooks
May 6th 04, 06:34 PM
"Peter Duniho" > wrote in message
...
> "ydm9" > wrote in message
> om...
> > [...]
> > Their current function always gets the GMT based on the effective date
> > of the flight. This is fine for 99% of the time. When a flight
> > crosses midnight and it's around time change dates, the effective date
> > of the flight might need to have a day added to it if the flight
> > crossed over midnight.
> >
> > Any input or direction would be greatly appreciated.
>
> I think your employers should hire a better programmer.
>
> If you think the problem you're working on now is hard, wait until you
have
> to deal with a flight that crosses the International Date Line. I'm
> guessing your head will explode.
That crosses the Date Line overnight. The LA-Auckland flights leave in the
evening and arrive in the morning 2 days later. The return flights leave in
the evening and arrive that same morning.
-- David Brooks
John Gaquin
May 6th 04, 08:21 PM
I recall looking at a flight schedule some years ago for a local carrier in
the Samoa area, I believe. They had a late-night inter-island flight that
arrived the day before it departed.
"David Brooks" > wrote in message > >
> > If you think the problem you're working on now is hard, wait until you
> have
> > to deal with a flight that crosses the International Date Line. I'm
> > guessing your head will explode.
>
> That crosses the Date Line overnight. The LA-Auckland flights leave in the
> evening and arrive in the morning 2 days later. The return flights leave
in
> the evening and arrive that same morning.
>
> -- David Brooks
>
>
Cub Driver
May 6th 04, 09:31 PM
>They had a late-night inter-island flight that
>arrived the day before it departed.
Humberto Ecco spun this conceit into a fat novel called The Island of
the Day Before.
It wasn't very goodl.
all the best -- Dan Ford
email: (put Cubdriver in subject line)
The Warbird's Forum www.warbirdforum.com
The Piper Cub Forum www.pipercubforum.com
Viva Bush! blog www.vivabush.org
David Brooks
May 6th 04, 11:51 PM
You could fairly easily do that within the continental US.
-- David Brooks
"John Gaquin" > wrote in message
...
> I recall looking at a flight schedule some years ago for a local carrier
in
> the Samoa area, I believe. They had a late-night inter-island flight that
> arrived the day before it departed.
>
>
> "David Brooks" > wrote in message > >
> > > If you think the problem you're working on now is hard, wait until you
> > have
> > > to deal with a flight that crosses the International Date Line. I'm
> > > guessing your head will explode.
> >
> > That crosses the Date Line overnight. The LA-Auckland flights leave in
the
> > evening and arrive in the morning 2 days later. The return flights leave
> in
> > the evening and arrive that same morning.
> >
> > -- David Brooks
> >
> >
>
>
John Gaquin
May 7th 04, 03:14 AM
"David Brooks" > wrote in message
news:409ac165
> You could fairly easily do that within the continental US.
Technically, yes. I suppose I should have been more precise. This flight
arrived not just "the day before" it departed, but [almost] "a" day before.
IIRC it was about a 30 min flight that arrived about 22 or 23 hours before
it departed.
> "John Gaquin" > wrote in message
> ...
> > I recall looking at a flight schedule some years ago for a local carrier
> in
> > the Samoa area, I believe. They had a late-night inter-island flight
that
> > arrived the day before it departed.
Well aware of the IDL. Programming it is the easy part. Knowing what
to program is the problem. Seeing that I have not received the
solution lets me know that I am in the majority of dumb folks.
"Peter Duniho" > wrote in message >...
> "ydm9" > wrote in message
> om...
> > [...]
> > Their current function always gets the GMT based on the effective date
> > of the flight. This is fine for 99% of the time. When a flight
> > crosses midnight and it's around time change dates, the effective date
> > of the flight might need to have a day added to it if the flight
> > crossed over midnight.
> >
> > Any input or direction would be greatly appreciated.
>
> I think your employers should hire a better programmer.
>
> If you think the problem you're working on now is hard, wait until you have
> to deal with a flight that crosses the International Date Line. I'm
> guessing your head will explode.
>
> Pete
Thanks for the replay.
I see you use a time of flight (we call that the elapsed time of the
flight). We calculate that by converting the depart and arrive local
times to GMT times. But, to get the correct GMT offset, you have to
know the correct date. To know the correct date, you need to know if
it is the depart date or the day after. If I can determine what date
to use to get the arrive station GMT offset, I'll have it made.
(Teacherjh) wrote in message >...
> >>
> In order to get the correct GMT offset for the arrive station, I have
> to know the correct date to use.
> <<
>
> Just let your times go past 24:00 and less than 00:00. Then do a check, and
> add or subtract a day based on the result. For example, starting with 23:00,
> five hours of flight, and a +2 hour offset, you end up with 30:00 on (say)
> Tuesday. Then you check to see if the time is <00:00 or >=24:00. Since it's
> >+24:00, add a day and take away 24:00. So now we have 06:00 Wednesday.
>
> Same idea, if you start out at 03:00 Friday, a two hour flight, and a seven
> hour offset (the other way) (in the Space Shuttle, presumably!), you end up
> with -06:00 (six hours below zero). We check to see if this is <00:00, and if
> so, ADD 24:00 and subtract a day. We h ave 18:00 Thursday.
>
> Limit checks like this are common for all date and time conversions (in fact,
> any modulo arithmetic with carry). You'll need to check to see if the date
> goes past Sunday (day 7) so it can cycle "back" to Monday (day 1), see if you
> passed 31 or 30 or 29 or 28 (depending on month and year) so it can cycle back
> to the first of Next Month, see if we passed December, etc.
>
> Jose
John Gaquin
May 7th 04, 06:31 PM
"ydm9" > wrote in message
> Programming it is the easy part. Knowing what
> to program is the problem. Seeing that I have not received the
> solution lets me know that I am in the majority of dumb folks.
If that's how your logic works, your difficulties are understandable. Why
are you asking pilots to answer programming questions? Would you ask
programmers how to fly? There are a number of programming newsgroups that
might be able to help.
John Gaquin
May 7th 04, 06:37 PM
"ydm9" > wrote in message
> If I can determine what date
> to use to get the arrive station GMT offset, I'll have it made.
I would think it would make more sense to input the GMT correction, then
calculate any cross-midnight adjustment based on the flight arrival time.
The GMT offset will be a constant (+/- 1 if that locale uses DST) regardless
of your arrival time. Boston is always GMT-4 or -5, and there are only two
dates when the variable comes into play.
Dima Volodin
May 7th 04, 07:03 PM
"John Gaquin" > wrote in message
...
>
> "ydm9" > wrote in message
>
> > Programming it is the easy part. Knowing what
> > to program is the problem. Seeing that I have not received the
> > solution lets me know that I am in the majority of dumb folks.
>
> If that's how your logic works, your difficulties are understandable. Why
> are you asking pilots to answer programming questions? Would you ask
> programmers how to fly?
Well, ummm, some programmers _are_ pilots :-)
Dima
Teacherjh
May 7th 04, 11:49 PM
>>
We calculate that by converting the depart and arrive local
times to GMT times. But, to get the correct GMT offset, you have to
know the correct date. To know the correct date, you need to know if
it is the depart date or the day after. If I can determine what date
to use to get the arrive station GMT offset, I'll have it made.
<<
You need to know which way you are counting, and how many hours you are
counting. I am thinking you start at Rome, and fly west to Calfornia. You
have a time difference of MINUS 8? hours. Sometimes this puts you on the same
day, and sometimes not. This has to do with what time it is in Rome. If
taking eight hours takes you "below zero" then it is the previous day.
Jose
--
(for Email, make the obvious changes in my address)
John Gaquin
May 8th 04, 02:21 AM
"Dima Volodin" > wrote in message news:ecQmc.12197
>
> Well, ummm, some programmers _are_ pilots :-)
Well, duh! Some surgeons are also woodworkers, but you wouldn't go on a
woodworking NG and ask questions about surgical procedure.
Cub Driver
May 8th 04, 11:18 AM
> Boston is always GMT-4 or -5, and there are only two
>dates when the variable comes into play.
Of course planes depart London on local time, not Zulu.
The U.S. & Britain don't change summer/winter times necessarily on the
same date. (I think the gap is most noticable in autumn.)
(Or perhaps that's what you were saying? But as I recall, the autumn
gap is a couple of weeks.)
all the best -- Dan Ford
email: (put Cubdriver in subject line)
The Warbird's Forum www.warbirdforum.com
The Piper Cub Forum www.pipercubforum.com
Viva Bush! blog www.vivabush.org
Dima Volodin
May 8th 04, 02:54 PM
John Gaquin wrote:
>
> "Dima Volodin" > wrote in message news:ecQmc.12197
> >
> > Well, ummm, some programmers _are_ pilots :-)
>
> Well, duh! Some surgeons are also woodworkers, but you wouldn't go on a
> woodworking NG and ask questions about surgical procedure.
Some voters are pilots, and they don't seem to have any problems
discussing all things politics on r.a.p :-)
Dima
John Gaquin
May 8th 04, 06:18 PM
"Cub Driver" > wrote in message
...
>
> > Boston is always GMT-4 or -5, and there are only two
> >dates when the variable comes into play.
>
> Of course planes depart London on local time, not Zulu.
>
> The U.S. & Britain don't change summer/winter times necessarily on the
> same date. (I think the gap is most noticable in autumn.)
No, I meant that there are only two dates when the variable comes into play
for each station. You run the whole thing in GMT, from the computer's pov.
John Gaquin
May 8th 04, 06:21 PM
"Dima Volodin" > wrote in message
...
>
> Some voters are pilots, and they don't seem to have any problems
> discussing all things politics on r.a.p :-)
True, but the OP was asking specific, technical questions on an unrelated
NG, then getting aggravated when good solutions were not forthcoming. Makes
no sense.
David Brooks
May 10th 04, 06:27 PM
"Cub Driver" > wrote in message
...
>
> > Boston is always GMT-4 or -5, and there are only two
> >dates when the variable comes into play.
>
> Of course planes depart London on local time, not Zulu.
>
> The U.S. & Britain don't change summer/winter times necessarily on the
> same date. (I think the gap is most noticable in autumn.)
>
> (Or perhaps that's what you were saying? But as I recall, the autumn
> gap is a couple of weeks.)
Nit - UK springs ahead a week before US. They fall back on the same date.
-- David Brooks
David Brooks
May 10th 04, 06:34 PM
"Cub Driver" > wrote in message
...
>
> > Boston is always GMT-4 or -5, and there are only two
> >dates when the variable comes into play.
>
> Of course planes depart London on local time, not Zulu.
>
> The U.S. & Britain don't change summer/winter times necessarily on the
> same date. (I think the gap is most noticable in autumn.)
Hmmm... If we are offering the OP the strategy of converting all local times
to UTC (which requires knowledge of local timezones and daylight savings
rules), there is still an ambiguity. On the day the clocks go back, the
local time of 0130 happens twice. Which occurrence do you use? Weighty
matters indeed.
-- David Brooks
Peter Duniho
May 10th 04, 07:59 PM
"David Brooks" > wrote in message
...
> [...] On the day the clocks go back, the
> local time of 0130 happens twice.
It's worse than that. Every local time between 0130 and 0230 happens twice.
David Brooks
May 10th 04, 08:27 PM
"Peter Duniho" > wrote in message
...
> "David Brooks" > wrote in message
> ...
> > [...] On the day the clocks go back, the
> > local time of 0130 happens twice.
>
> It's worse than that. Every local time between 0130 and 0230 happens
twice.
I only used that by way of example, and was hoping nobody would pick the
nit. But it's actually 0100 to just-before-0200 that happens twice.
Reminds me of a Car Talk stumper. In brief: two friends were talking on the
phone, one in an East Coast state and one in a West Coast state. While
talking they discover it's the same time for both of them. How come? The
fact I bring it up in this thread is a big hint.
Oh, they're both pilots. That's utterly irrelevant, but brings this back
on-topic.
-- David Brooks
Peter Duniho
May 11th 04, 03:25 AM
"David Brooks" > wrote in message
...
> I only used that by way of example, and was hoping nobody would pick the
> nit. But it's actually 0100 to just-before-0200 that happens twice.
I know...I was just checking to see if you knew. :)
As far as nit-picking goes...I thought that's the point in the thread that
we'd arrive at already. :)
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.