A class based implementation of the British Swimming/SPORTSYSTEMS Equivalent Time Algorithm. Written in-house by Chester-le-Street ASC.
composer require clsasc/equivalent-time
use CLSASC\EquivalentTime\EquivalentTime;
$object = new EquivalentTime("25m", "200 Free", 116.68);
Parameter 1 is the length of the source pool, Parameter 2 is the event and
Parameter 3 is the time, formatted as a float, seconds.hundreds - You may wish
to cast this to a float, just in case your code takes in time as a string.
Choose if you want the output to be formatted as a string or a float. Float
output is default, but you can get it as an ‘alpha format’ (MM:SS:H) string by
invoking the setOutputAsString(); method on your object. Switch back by
calling the setOutputAsReal(); method on your object.
Get your output. PHP $object->getConversion("50m"); Where the
parameter is the length of pool you would like your time to be converted to.
getConversion($length) method on your conversion object as
many times as you wish. To convert another time, create a new object and the old
one will be garbage collected by PHP after it is no longer referenced.Full API Style documentation is available (phpDocumentor).
Source Pool Length names are shown as they should be entered as a string to the converter object.
The same strings as listed below should be used when calling a method to obtain
a converted time, though you should always try {...} catch (Exception ...) {...}
when calling the method as if the event cannot be swum in the distance you have
requested, the converter will throw an exception to alert you to the problem.
20m25m33 1/3m50m20y25y26 2/3y27 1/2y33 1/3yBelow is a list of events accepted by the time converter. Some events are only
accepted for a subset of source pool lengths, described by the list following
the event name. If you do try to create an object with an event and source pool
length which are incompatible, an exception will be thrown, which you should
catch....
Event names are shown as they should be entered as a string to the converter object.
50 Free is allowed with the following source pool lengths;
50m25m27 1/2y25y100 Free200 Free400 Free800 Free1500 Free is not allowed with the following source pool lengths;
33 1/3y20y50 Breast is allowed with the following source pool lengths;
50m25m27 1/2y25y100 Breast200 Breast50 Fly is allowed with the following source pool lengths;
50m25m27 1/2y25y100 Fly200 Fly50 Back is allowed with the following source pool lengths;
50m25m27 1/2y25y100 Back200 Back200 IM400 IMThe system will throw exceptions for error conditions. Please read the docs for full details on these.