Well there were a wide range of offences which could mean detention: Insubordination – striking a senior officer – wilful disobedience – self inflicted injuries – theft etc and absence as well.
It is possible that it was for being AWOL: for a period of absence over 36 hours, if it was by a repeat offender, or if was aggravated (i.e. there were other offences as well) then offenders could face detention of up to 30 days;
To have 30 days just for failing to return to ship on time would probably be thought of as harsh if it were a first offence, but if he was always in trouble etc., or if combined with something else, such as insubordination then it might be considered OK