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’.
Ropner Shipping Co. Ltd. v Cleeves Western Valleys Anthracite Collieries Ltd., (1927) 27 Ll.L.Rep. 317 by Sargant LJ at p.320:
In order that demurrage may be claimed by the owners they must at least do nothing to prevent the vessel being available and at the disposal of the charterers for the purpose of completing the loading of the cargo.
Blue Anchor Line Ltd. v Alfred C. Toepfer International (The Union Amsterdam)  2 Lloyd’s Rep. 432 per Parker J at p.436:
…far from doing nothing to prevent the vessel being available, owners have, by negligent navigation or management, so prevented her and, as Lord Justice Bankes said, it does not lie in their mouths to say that the vessel was being detained by the charterers during the period when by their negligence she was grounded.
Per Colman J in Alphapoint Shipping Ltd. v Rotem Amfert Negev Ltd. and Another (The Agios Dimitrios)  1 Lloyd’s Rep. 23 at para 19-20:
19. In considering the grounds of this application and the arbitrators' reasons it is important to keep very clearly in mind the distinction in the remedies provided by cl. 23(b) and cl. 25. If there has been a breach of cl. 23(b) by omission of the shipowners to provide clean holds ready and suitable to receive the intended cargo and notice of readiness is given and accepted by charterers, the question whether the shipowners have complied with their obligation is not necessarily concluded, for the holds may in truth be unclean and unfit and that condition may not have been reasonably apparent when the notice of readiness was accepted. Time will then begin to run and, in the absence of a provision such as cl. 25 which stops it running, it will continue to run until completion of loading. If in the meantime, there is a delay while the holds are cleaned and the shipowners' breach thereby cured, the charterers will be entitled to damages for that breach which may at least in part be quantified by reference to the amount of such demurrage as may have occurred. The demurrage in respect of the delay period will not then be recoverable because the damages due to the charterers would be set off against the demurrage otherwise due to the shipowners. In such a case the charterers would have the burden of proving their damages claim by establishing that the relevant period of demurrage time had been incurred, as a matter of causation, by reason of the shipowners' breach, viz, the need to clean the holds.
20. …The effect of cl. 25 in the present case is thus that if time is lost by reason of the failure of the crew to perform functions relevant to loading and that causes delay in loading, the period of delay will be deducted from the used laytime or if the vessel is already on demurrage from the time on demurrage. This clause clearly does not depend on the charterers establishing that the shipowners were in breach by reason of such crew failure, but merely on the fact of such crew failure and the consequent delay. Further, the process of quantification of the relevant deduction of time has nothing to do with whether the charterers have suffered a net financial loss due to the crew’s failure. The only relevant currency is that of lost time.