You might also consider giving $max_periods a default [ function duration($seconds, $max_periods = 6) ]
thanks much btw!