Time and ISPs

Grids of imbalance settlement periods in a time zone, DST days with 92 or 100 quarter hours, windows from local times, ISP labels, slices and series.

On this page

The ISP grid#

An imbalance settlement period (ISP) is the unit everything is settled in: 15 minutes in most of Europe. A Grid is a run of ISPs of equal length from a start instant, numbered from 1 the way UFTP numbers them per day, and labelled in a time zone.

Grid::day builds the ISPs of one local date, from its start of day to the next. On the days the clocks change, a Central European day has 92 (spring) or 100 (autumn) quarter hours instead of 96:

use flexibility::jiff::{civil::date, tz::TimeZone};
use flexibility::{Grid, IspDuration};

let berlin = TimeZone::get("Europe/Berlin")?;
let isp = IspDuration::FIFTEEN_MINUTES;
assert_eq!(Grid::day(date(2026, 3, 29), &berlin, isp)?.count(), 92);
assert_eq!(Grid::day(date(2026, 10, 25), &berlin, isp)?.count(), 100);
assert_eq!(Grid::day(date(2026, 12, 1), &berlin, isp)?.count(), 96);

Any IANA zone works; the database is bundled, so the result does not depend on the machine. IspDuration::from_minutes accepts any length that divides a day (1, 5, 15, 30, 60 minutes and so on). A day that is not a whole number of ISPs, such as a 30-minute DST shift with one-hour ISPs, is refused. Grid::new(start, isp, count, zone) builds a grid that is not a day. A grid holds at most MAX_ISPS (527 040, a leap year of one-minute ISPs).

Two grids are equal when start, ISP length, count and numbering are equal. The zone is how a grid is shown and how local times are read; with_zone relabels a grid without changing its ISPs.

Windows from local time#

A Window is a non-empty half-open interval [from, until) of instants. Grid::window builds one from local wall-clock times on the grid's date, and Grid::isps gives the ISPs it overlaps (even partly):

use flexibility::jiff::{civil::{date, time}, tz::TimeZone};
use flexibility::{Grid, IspDuration};

let berlin = TimeZone::get("Europe/Berlin")?;
let grid = Grid::day(date(2026, 12, 1), &berlin, IspDuration::FIFTEEN_MINUTES)?;
let evening = grid.window(time(17, 0, 0, 0), time(19, 0, 0, 0))?;
assert_eq!(grid.isps(evening), Some(69..=76));

An until at or before from is on the next day, so 22:00 to 02:00 crosses midnight. Grid::local(time) gives the instant of one local time on the grid's date.

A local time the clocks skip or show twice is refused, not guessed:

2026-03-29 02:30:00 in Europe/Berlin is skipped: the clocks jump over it
2026-10-25 02:30:00 in Europe/Berlin is ambiguous: the clocks show it twice

The hint on that error is the remedy: on a DST day, state the window as instants with Window::new(from, until).

ISP labels#

Every error, violation, explanation and settlement line names its ISP as an IspLabel: the number, the local interval and the UTC offset at its start.

ISP 69 (17:00–17:15 +01:00)

On the repeated hour of an autumn day the offset tells the two 02:00 ISPs apart: ISP 9 (02:00–02:15 +02:00) and ISP 13 (02:00–02:15 +01:00). Grid::label(isp) returns the label, Grid::interval(isp) the window, and Grid::isp_at(instant) the ISP containing an instant.

Slices keep the day's numbers#

Grid::slice(69..=73) is a grid of its own that keeps the day's ISP numbers: its first ISP is 69, not 1. A settlement over the evening therefore names the ISPs that UFTP messages and meter data name.

let five = grid.slice(69..=73)?;
assert_eq!(five.first(), 69);
assert_eq!(five.numbers(), 69..=73);
assert_eq!(five.label(69).unwrap().to_string(), "ISP 69 (17:00–17:15 +01:00)");

Series#

A Series<T> holds exactly one value per ISP of its grid; Series::new refuses any other length (a DST day needs 92 or 100 values). Series::filled repeats one value.

MethodDoes
get(isp), iter(), values()read by ISP number, or in order
map, try_maptransform every value, on the same grid
zip_with(&other, f)combine ISP by ISP; another grid is Error::GridMismatch
slice(69..=76)the values of a run of ISPs, on the sliced grid
over(window)the values of the ISPs a window overlaps: a day's measurement cut to an event
energy()Σ power × ISP length, exact (for Series<Power>)

Values on different grids are never combined. Every operation over two series checks that they are on the same grid first.

Next: Limits and envelopes, which put bounds on those ISPs.