dev-master
9999999-devProvides TWIG helpers for distance and time stuff
MIT
The Requires
by dantleech
distance time
Provides TWIG helpers for distance and time stuff
This bundle adds some useful time and distance integrations:, (*1)
Note that when we talk about "stopwatch" here it refers to the format of the text, ie. hh:mm:ss., (*2)
By default all distances are assumed to be normalized as meters, you can change this value in the configuration as follows:, (*3)
dtl_time_distance: normalized_distance_unit: m
format_distance ~~~~~~~~~~~~~~~, (*4)
Convert the given normalized distance to the specified unit:, (*5)
{# Format 20km (in meters) to miles #} {{ 2000|format_distance('miles') }} {# Format 20km (in meters) to foot with a precision of 4 #} {{ 2000|format_distance('ft', 4) }}
Format a given number of seconds as "stopwatch" (hh:mm:ss):, (*6)
{# 1 hour will display as 01:00:00 #} {{ 3600|seconds_to_stopwatch }} {# 2 seconds will display as 00:00:02 #} {{ 2|seconds_to_stopwatch }} {# 1 week will display as 168:00:00 #} {{ 604800|seconds_to_stopwatch }}
Format average pace (i.e. time per distance unit) for given time and distance:, (*7)
{# If you ran 10k in 47 minutes you would do 00:07:34 - 7 minutes, 34 seconds per mile #} {{ 2820|average_pace(10, 'miles') }} {# Default is km, but will accept any of the distance units #} {{ 2820|average_pace(10) }}
Format average speed acccording to given distance unit:, (*8)
{# If you ran 10k in 47 minutes you run at 7.93 miles per hour #} {{ 2820|average_speed(10, 'miles') }}
The distance form type accepts the following formats, (*9)
All values are converted to kilometers internally., (*10)
The stopwatch type accepts all values accepted by mktime
with the addition of the stopwatch format hh:mm:ss
., (*11)
Provides TWIG helpers for distance and time stuff
MIT
distance time