[Canonical page](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/time-range/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# TimeRange

One interval of working hours within a day. A calendar's daily hours are a list of these ranges: [`Worktime::hours`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/worktime.md#hours>) for the regular week and [`DayRule::Hours`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/day-rule.md>) for a date exception. There's no constructor; build it with a struct literal.

## Declaration

```rust
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TimeRange {
    pub start: u16,
    pub end: u16,
}
```

## Fields

### start

```rust
pub start: u16
```

Start of the range in minutes since midnight. Valid values are `0` to `1439` (00:00 to 23:59).

### end

```rust
pub end: u16
```

End of the range in minutes since midnight. Valid values are `0` to `1440`; `1440` is 24:00.

When `end` is less than or equal to `start`, the range crosses midnight: it runs from `start` to `end` on the next day and belongs to the day it starts on. `{ start: 1320, end: 360 }` is 22:00 to 06:00. When `end` equals `start`, the range covers 24 hours.

A `start` of `1440` or more, or an `end` above `1440`, fails validation of the [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/project-data.md>) that holds the calendar. The error is an [`InputError`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/errors/input-error.md>) of kind `Validation`, with the message `hour range must be within 00:00..24:00` and a path such as `calendars[0].worktime.hours` or `calendars[0].worktime.dates[2026-08-14]`.

## Example

A calendar with a night shift from 22:00 to 06:00:

```rust
use plen_core::{CalendarData, TimeRange, Worktime};

fn main() {
    let night = CalendarData {
        id: "night".into(),
        worktime: Some(Worktime {
            hours: Some(vec![TimeRange {
                start: 22 * 60,
                end: 6 * 60,
            }]),
            ..Default::default()
        }),
    };
    println!("{night:?}");
}
```

## Related

- [`Worktime`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/worktime.md>) - holds the regular daily hours
- [`DayRule`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/day-rule.md>) - sets other hours for one date
- [`CalendarData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/calendar-data.md>) - the calendar the hours belong to
- [Working time and calendars](<https://docs.dhtmlx.com/planning-engine/rust/scheduling/working-time-calendars.md>) - defining working hours, including night shifts
