AvgasDinosaur,
How long does it take to actually build an A340-600?
How long is a piece of string?
You can say it ends with first flight, but where do you start?
With the arrival of the first section on the final assembly jigs?
With first metal being cut?
With the first purchase orders going out for long-lead items, that have the aircraft's number on it?
Work on some long-lead items may easily start a couple of years before.