# RationalTime

> A point in time, or a length of it, as a value over a rate.

Symbols in this group are spelled `otio_rational_time_…`. An SDK drops that prefix.

## `add`

`otio_rational_time_add` · method

Returns the sum of two times, at the higher of the two rates.

```c
OtioRationalTime otio_rational_time_add(OtioRationalTime left, OtioRationalTime right);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `left` | `OtioRationalTime` | receiver |
| `right` | `OtioRationalTime` | input |

## `almost_equals`

`otio_rational_time_almost_equal` · method

Returns whether two times are within `delta` of each other.

```c
bool otio_rational_time_almost_equal(
    OtioRationalTime left,
    OtioRationalTime right,
    double delta);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `left` | `OtioRationalTime` | receiver |
| `right` | `OtioRationalTime` | input |
| `delta` | `double` | input |

## `ceil`

`otio_rational_time_ceil` · getter

Returns the time rounded towards positive infinity.

```c
OtioRationalTime otio_rational_time_ceil(OtioRationalTime time);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |

## `compare`

`otio_rational_time_compare` · method

Orders two times: -1 if `left` is earlier, 1 if later, 0 if the same.

A comparison involving a NaN has no answer, and reports 0.

```c
int32_t otio_rational_time_compare(OtioRationalTime left, OtioRationalTime right);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `left` | `OtioRationalTime` | receiver |
| `right` | `OtioRationalTime` | input |

## `duration_from_start_end_time`

`otio_rational_time_duration_from_start_end_time` · free

Returns how long it is from one instant to another, the end excluded.

```c
OtioRationalTime otio_rational_time_duration_from_start_end_time(
    OtioRationalTime start_time,
    OtioRationalTime end_time_exclusive);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `start_time` | `OtioRationalTime` | input |
| `end_time_exclusive` | `OtioRationalTime` | input |

## `duration_from_start_end_time_inclusive`

`otio_rational_time_duration_from_start_end_time_inclusive` · free

Returns how long it is from one instant to another, the end included.

```c
OtioRationalTime otio_rational_time_duration_from_start_end_time_inclusive(
    OtioRationalTime start_time,
    OtioRationalTime end_time_inclusive);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `start_time` | `OtioRationalTime` | input |
| `end_time_inclusive` | `OtioRationalTime` | input |

## `equals`

`otio_rational_time_equal` · method

Returns whether two times are the same instant.

Times at different rates that name the same instant compare equal; this is upstream's `==`, not a field-by-field comparison. For that, use [`otio_rational_time_strictly_equal`].

```c
bool otio_rational_time_equal(OtioRationalTime left, OtioRationalTime right);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `left` | `OtioRationalTime` | receiver |
| `right` | `OtioRationalTime` | input |

## `floor`

`otio_rational_time_floor` · getter

Returns the time rounded towards negative infinity.

```c
OtioRationalTime otio_rational_time_floor(OtioRationalTime time);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |

## `from_frames`

`otio_rational_time_from_frames` · constructor

Builds a time from a frame number at a rate.

```c
OtioRationalTime otio_rational_time_from_frames(double frame, double rate);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `frame` | `double` | input |
| `rate` | `double` | input |

## `from_seconds`

`otio_rational_time_from_seconds` · constructor

Builds a time from a number of seconds, at a rate of one.

```c
OtioRationalTime otio_rational_time_from_seconds(double seconds);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `seconds` | `double` | input |

## `from_seconds_at_rate`

`otio_rational_time_from_seconds_at_rate` · constructor

Builds a time from a number of seconds at a rate.

```c
OtioRationalTime otio_rational_time_from_seconds_at_rate(double seconds, double rate);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `seconds` | `double` | input |
| `rate` | `double` | input |

## `from_time_string`

`otio_rational_time_from_time_string` · constructor

Reads a time from a `[-]HH:MM:SS.sss` time string at a rate.

```c
OtioStatus otio_rational_time_from_time_string(
    const char *time_string,
    double rate,
    OtioRationalTime *out_time,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time_string` | `text` | input |
| `rate` | `double` | input |
| `out_time` | `OtioRationalTime` | output |
| `out_error` | `text` | error |

## `from_timecode`

`otio_rational_time_from_timecode` · constructor

Reads a time from a `HH:MM:SS:FF` timecode at a rate.

```c
OtioStatus otio_rational_time_from_timecode(
    const char *timecode,
    double rate,
    OtioRationalTime *out_time,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `timecode` | `text` | input |
| `rate` | `double` | input |
| `out_time` | `OtioRationalTime` | output |
| `out_error` | `text` | error |

## `is_valid`

`otio_rational_time_is_valid` · getter

Returns whether a time is usable: both parts finite and the rate positive.

```c
bool otio_rational_time_is_valid(OtioRationalTime time);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |

## `negate`

`otio_rational_time_negate` · getter

Returns the time with its sign flipped.

```c
OtioRationalTime otio_rational_time_negate(OtioRationalTime time);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |

## `rescaled_to`

`otio_rational_time_rescaled_to` · method

Returns the same instant expressed at another rate.

```c
OtioRationalTime otio_rational_time_rescaled_to(OtioRationalTime time, double rate);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `rate` | `double` | input |

## `rescaled_to_time`

`otio_rational_time_rescaled_to_time` · method

Returns the same instant expressed at another time's rate.

```c
OtioRationalTime otio_rational_time_rescaled_to_time(
    OtioRationalTime time,
    OtioRationalTime other);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `other` | `OtioRationalTime` | input |

## `round`

`otio_rational_time_round` · getter

Returns the time rounded to the nearest whole value, halves away from zero.

```c
OtioRationalTime otio_rational_time_round(OtioRationalTime time);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |

## `strictly_equals`

`otio_rational_time_strictly_equal` · method

Returns whether two times have the same value and the same rate.

```c
bool otio_rational_time_strictly_equal(OtioRationalTime left, OtioRationalTime right);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `left` | `OtioRationalTime` | receiver |
| `right` | `OtioRationalTime` | input |

## `subtract`

`otio_rational_time_subtract` · method

Returns the difference of two times, at the higher of the two rates.

```c
OtioRationalTime otio_rational_time_subtract(
    OtioRationalTime left,
    OtioRationalTime right);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `left` | `OtioRationalTime` | receiver |
| `right` | `OtioRationalTime` | input |

## `to_frames`

`otio_rational_time_to_frames` · getter

Returns the frame number this time falls on.

```c
int32_t otio_rational_time_to_frames(OtioRationalTime time);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |

## `to_frames_at_rate`

`otio_rational_time_to_frames_at_rate` · method

Returns the frame number this time falls on at another rate.

```c
int32_t otio_rational_time_to_frames_at_rate(OtioRationalTime time, double rate);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `rate` | `double` | input |

## `to_nearest_timecode_at`

`otio_rational_time_to_nearest_timecode_at` · method

Writes a time as a timecode, rounding to the nearest frame first.

```c
OtioStatus otio_rational_time_to_nearest_timecode_at(
    OtioRationalTime time,
    double rate,
    OtioDropFrame drop_frame,
    OtioBuffer *out_timecode,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `rate` | `double` | input |
| `drop_frame` | `OtioDropFrame` | input |
| `out_timecode` | `text` | output |
| `out_error` | `text` | error |

## `to_seconds`

`otio_rational_time_to_seconds` · getter

Returns the time in seconds.

```c
double otio_rational_time_to_seconds(OtioRationalTime time);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |

## `to_time_string`

`otio_rational_time_to_time_string` · getter

Writes a time as a `HH:MM:SS.sss` time string.

```c
OtioStatus otio_rational_time_to_time_string(
    OtioRationalTime time,
    OtioBuffer *out_string,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `out_string` | `text` | output |
| `out_error` | `text` | error |

## `to_timecode`

`otio_rational_time_to_timecode` · getter

Writes a time as a timecode at its own rate.

```c
OtioStatus otio_rational_time_to_timecode(
    OtioRationalTime time,
    OtioBuffer *out_timecode,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `out_timecode` | `text` | output |
| `out_error` | `text` | error |

## `to_timecode_at`

`otio_rational_time_to_timecode_at` · method

Writes a time as a timecode at a given rate and drop-frame setting.

```c
OtioStatus otio_rational_time_to_timecode_at(
    OtioRationalTime time,
    double rate,
    OtioDropFrame drop_frame,
    OtioBuffer *out_timecode,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `rate` | `double` | input |
| `drop_frame` | `OtioDropFrame` | input |
| `out_timecode` | `text` | output |
| `out_error` | `text` | error |

## `value_rescaled_to`

`otio_rational_time_value_rescaled_to` · method

Returns what this time's value would be at another rate.

```c
double otio_rational_time_value_rescaled_to(OtioRationalTime time, double rate);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `time` | `OtioRationalTime` | receiver |
| `rate` | `double` | input |

---

Page: https://otio-rust-docs.vercel.app/reference/rational-time/
