> For the complete documentation index, see [llms.txt](https://docs.dbnetsoft.com/dbnetsoft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dbnetsoft.com/dbnetsoft/raceresultexchange/operation-modes/displayboard/displayboard-brands/alge-timing-gaz-d-line/scripting/clock-runtime-gaptime.md).

# Clock, Runtime, Gaptime

### Show clock before start, runtime after start and gap time after winner finish <a href="#use-of-globals" id="use-of-globals"></a>

The following script allows to show the current clock before the start of the race, a runtime during the race and a gap time to winner as soon as the first athlete finishes.

This can be achieved by having the race start TOD and the winner TOD available in a RR12 list. The actual content of these values depend on your event file setup.

<figure><img src="https://dbnetsoft.github.io/RaceResultExchangeDocumentation/scripting/globals_list.png" alt="" width="375"><figcaption></figcaption></figure>

This list is then pulled via RRExchange globals feature periodically into the software.

<figure><img src="https://dbnetsoft.github.io/RaceResultExchangeDocumentation/scripting/globals.png" alt="" width="375"><figcaption></figcaption></figure>

The pulled global list entries are available as variables in each script then. They are identified by .First., e.g. `GlobalsName.First.Starttime` for a RR12 field named `Starttime` in a globals list `GlobalsName`.

```
{{
# Get current TOD and convert to seconds
now = timespan.Now | ToSeconds

# Fetch race start time and winner time from Globals List and convert to seconds (this way RR12 field can be seconds or HH:mm:ss string
raceStartedAt = StartAndWinnerList.First.Starttime | ToSeconds
winnerFinishedAt = StartAndWinnerList.First.Winnertime  | ToSeconds

# Determine race states
isRaceStarted = raceStartedAt > 0

# Determine output based on is race started or not
if isRaceStarted 
    # Race is started, check for winner time is present    
    isWinnerFinished = winnerFinishedAt > 0

    if (isWinnerFinished)
        # Winnner is finished, show gap time

        # Calculate gap time
        timeSinceWinner = now - winnerFinishedAt
        timeSinceWinner | gaz.Format "Seconds" false

    else 
        # No winner present, show running time


        # Calculate runtime
        timeSinceStart = now - raceStartedAt
    timeSinceStart | gaz.Format "Seconds" false

    end

else 
    # Before Start

   ""


end

}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.dbnetsoft.com/dbnetsoft/raceresultexchange/operation-modes/displayboard/displayboard-brands/alge-timing-gaz-d-line/scripting/clock-runtime-gaptime.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
