-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The Sessions.duration field is saved in integer seconds. In order to be human readable, it needs to be converted to h:mm:ss format with:
(new FrozenTime($session->duration))->format('G:i:s')
It might happen that it has a null value. In this case, we need not to show a value (or show 0:00:00 at least). Without conversion, this null value will make FrozenTime constructor create a current timestamp value, which is not the goal here. This is solved like that:
isset($session->duration) ? (new FrozenTime($session->duration))->format('G:i:s') : ''
This conversion is done, right now, on the View layer, in many template files.
It would be more coherent, efficient and error-proof to get the final value right from the Model layer. With the only exception of model methods where we need to take the value to calculate with it. Anyway, right now the field is only summed inside custom finders, so since we take the value, we only need to pass it to the View.
TO DO: study the best way to achieve this, being it using a Behavior or other.