There are many many variables to decide how long a crew member can work - it is called a Flying Duty Period (FDP) - for instance - number of sectors, the amount of rest preceeding their FDP, the number of pilots onboard, crew rest areas, are they acclimatised to local time? etc etc the list is almost endless.
An FDP will start when a crew member checks in for their flight, and there will be a limit - say for example 12 hours - which is set. If, however, things go wrong (like a divert or problems with ATC slots, etc) the commander has the option to use 'discretion' - which basically means he can work beyond the 12 hours - up to a maximum of 3 hours extra (so 15 hrs total) provided he feels that the flight can be made safely and the crew won't be too tired in an emergency.
It's all very boring and very long winded, and every airline has their own set of rules - they are called Flight Time Limitations (FTL). If you want to have a look at what FTL's are based upon - check out the CAP 371 document from the CAA http://www.caa.co.uk/application.asp...applicationid=11&mode=detail&id=22
Any questions, just ask
My pony plays the mamba . .