# Time Representation [VC 5.6 INT]

This section describes how time is handled in the system. There are five main categories related to time which will be discussed here: time bases, time positions (a.k.a. time codes), time intervals, time durations and time span.

This section can be divided into the following topics:

## Time bases

A time base describes how long one unit of time is in seconds using a ratio. This means that everything that has to do with time is done using rational numbers. For instance, ten seconds in the time base used by PAL (1/25) would be 250 units, or 250/25.

### Textual representations

When working with time bases it is sometimes necessary to construct textual representations which are human readable and can be more easily output and entered into the system. To that end the following textual representations are valid for time bases:

Its inverse as a rational number. The syntax is {

**denominator**}[:{**numerator**}], where numerator can be omitted if it’s value is one.A

__TimeBaseConstant__string

#### TimeBaseConstant

The following time base constants are currently defined:

PAL | 1/25 |

NTSC | 1001/30000 |

NTSC30 | 1/30 |

#### Examples

25, 30000:1001, 48000

PAL, NTSC

### XSL

*TimeBaseType* is the XML representation of a time base.

```
<xs:complexType name="TimeBaseType">
<xs:sequence>
<xs:element name="numerator" type="xs:int"/>
<xs:element name="denominator" type="xs:int"/>
</xs:sequence>
</xs:complexType>
```

#### Examples

```
<timeBase>
<numerator>1</numerator>
<denominator>25</denominator>
</timeBase>
```

## Time codes

A time code is a representation of a point in time in some time base.

### Textual representations

When working with time codes it is sometimes necessary to construct textual representations with are human readable and can be more easily output and entered into the system. To that end the following textual representations are valid for time codes:

A sample count and a time base. The syntax is {

**number of samples**}[@{**textual representation of time base**}], where the time base is optional and implicitly one second if omitted. Examples:`124`

,`124222@44100`

,`400@30000:1001`

,`400@NTSC`

.A decimal number. Example:

`124.25`

(will be treated as`12425/100`

or`497/4`

). This is strongly not recommended, as most sampling frequencies do not have a finite decimal representation!A decimal number and a time base. Example:

`124.25/PAL`

(will be treated as`12425/2500`

). This is also not recommended!The special constants -INF and +INF, representing the earlier than the earliest possible instant and later than the latest possible instant, respectively.

### XSL

*TimeCodeType* is the XML representation of a time code.

```
<xs:complexType name="TimeCodeType">
<xs:sequence>
<xs:element name="samples" type="xs:long"/>
<xs:element name="timeBase" type="tns:TimeBaseType"/>
</xs:sequence>
</xs:complexType>
```

#### Examples

```
<timeCode>
<samples>250</samples>
<timeBase>
<numerator>1</numerator>
<denominator>25</denominator>
</timeBase>
</timeCode>
```

## Time intervals

A time interval consists of two time codes: start and end. The time between them denotes the period of time which is of interest. Note that start and end specify an interval like [start,end) in mathematical notation. In other words, the end time code is not within the interval.

Specifying an interval where both time codes have different time bases is valid.

### XSL

```
<xs:complexType name="TimeIntervalType">
<xs:sequence>
<xs:element name="start" type="tns:TimeCodeType"/>
<xs:element name="end" type="tns:TimeCodeType"/>
</xs:sequence>
</xs:complexType>
```

### Examples

#### Interval in PAL

```
<!-- Seconds 10-20 in PAL -->
<interval>
<start>
<samples>250</samples>
<timeBase>
<numerator>1</numerator>
<denominator>25</denominator>
</timeBase>
</start>
<end>
<samples>500</samples>
<timeBase>
<numerator>1</numerator>
<denominator>25</denominator>
</timeBase>
</end>
</interval>
```

#### Mixed time bases

```
<!-- Approximately seconds 10-20. Start in PALs time base, end in NTSCs time base (for instance cutting from PAL to NTSC video) -->
<interval>
<start>
<samples>250</samples>
<timeBase>
<numerator>1</numerator>
<denominator>25</denominator>
</timeBase>
</start>
<end>
<samples>599</samples>
<timeBase>
<numerator>1001</numerator>
<denominator>30000</denominator>
</timeBase>
</end>
</interval>
```

## Time durations

A time duration is the length of a time interval. It can be calculated by subtracting the end time code from the start time code. This means it’s simply another time code, with its time line’s zero at the start of the interval.

## Time span

A time span is a interval between two __time codes__.

There are two notations. The first notation is by using two time instants and separate them with a hyphen (-). The first time instant is included in the interval, the second one is excluded. That is, in the interval 124-221, the instant corresponding to second 124 is included in the interval, but not the instant corresponding to second 221. (E.g., if there is an instant corresponding to second 220.9999999, it is included.)

The other notation is by using one time instant and one __time duration__, separate with a plus sign (+). The notation { **a** } `+`

{ **b** } is equivalent to { **a** } `-`

{ **a** + **b** }.