The usual solution in respect of duration of port stay is to allow an appropriate period time to cover loading and discharging, generally called ‘laytime’ or, sometimes, ‘lay days’, which is at the charterer’s free disposal, and to grant him the possibility, in case of need, of detaining the vessel beyond the agreed time, against payment of compensation to the owner for the use of the additional time; such compensation is called ‘demurrage’.
Postlethwaite v Freeland (1880) 5 App Cas 599 at 618, HL per Lord Blackburn:
It, therefore, seems very reasonable that the shipowner in making his bargain should require the merchant to make an estimate of the probable time of discharging the ship, and take on himself the risk of that time being exceeded; and then the shipowner can fix the payment he is willing to take with reference to this; and this has long been done by providing lay days and demurrage days for the discharge.
In the last edition of Abbott on Shipping, published while Lord Tenterden was living, it is said [5th Ed. p. 180]:
The usual clauses purporting that it is covenanted and agreed by and between the parties that a specified number of days shall be allowed for loading and unloading, and that it shall be lawful to detain the vessel for those purposes a farther specified time on payment of a daily sum, constitute a contract on the part of the freighter that he will not detain the ship for those purposes beyond the two designated periods; and if he does so detain her, he is liable to an action on the contract, in the form adapted to the nature of the instrument. If a ship be so detained, the daily rate of demurrage mentioned in the charterparty will in general be the measure of the damages to be paid; but it is not the absolute or necessary measure; more or less may be payable as justice may require, regard being had to the expense and loss incurred by the owner; and the amount must be settled by a jury if the parties cannot agree.
Nielsen v Wait (1885) 16 QBD 67 CA per Lord Esher MR at p.70:
There must be a stipulation as to the time to be occupied in the loading and in the unloading of the cargo. There must be a time, either expressly stipulated, or implied. If it is not expressly stipulated, then it is a reasonable time which is implied by the law; but either the law or the parties fix a time. Now when they do fix a time, how do they fix it? Why, they allow a certain number of days, during which, although the ship is at the disposal of the charterer to load or to unload the cargo, he does not pay for the use of the ship. That is the meaning of "lay days." It is a stipulation always in favour of the charterer.
Aldebaran Compania Maritima SA Panama v Aussenhandel AG Zurich (The Darrah),  AC 157 per Lord Diplock (p.164):
In consideration of the stipulated freight the charterer under such a charterparty is entitled to require the vessel to be available for use in the loading and discharging operation for such length of time as may be specified in the contract or, if not expressly specified, for such time as is reasonably required to complete the operation. The time for loading or discharging that is so specified and paid for in the freight is known as laytime. Strictly speaking laytime does not start until the vessel has completed the preceding loading voyage or carrying voyage and has become an arrived ship.