flexibility 0.1.2

Grid flexibility as exact, replayable arithmetic: limits, baselines, UFTP-exact settlement, and UFTP, EEBUS, S2, OpenADR, CSIP-AUS, IEC 104, CLS.EEDI converters.
Documentation
//! Fixtures shared by the integration tests.
#![allow(dead_code)]

use flexibility::jiff::Timestamp;
use flexibility::jiff::civil::{Date, date};
use flexibility::jiff::tz::TimeZone;
use flexibility::{Grid, IspDuration, Provenance, Window};

pub fn berlin() -> TimeZone {
    TimeZone::get("Europe/Berlin").expect("bundled zone")
}

/// 2026-12-01, Europe/Berlin, 15-minute ISPs: 96 ISPs.
pub fn day() -> Grid {
    day_of(date(2026, 12, 1))
}

pub fn day_of(d: Date) -> Grid {
    Grid::day(d, &berlin(), IspDuration::FIFTEEN_MINUTES).expect("day grid")
}

/// Local time on 2026-12-01 in Berlin.
pub fn at(hour: i8, minute: i8) -> Timestamp {
    date(2026, 12, 1)
        .at(hour, minute, 0, 0)
        .to_zoned_datetime(berlin())
        .expect("local time")
        .timestamp()
}

pub fn dso() -> Provenance {
    Provenance::new("dso.example", "order-42", at(12, 0))
}

pub fn fuse() -> Provenance {
    Provenance::new("site.example", "main-fuse", at(0, 0))
}

pub fn agr() -> Provenance {
    Provenance::new("agr.example", "plan-7", at(12, 0))
}

/// The window from `h1:m1` to `h2:m2` on 2026-12-01 in Berlin.
pub fn win(h1: i8, m1: i8, h2: i8, m2: i8) -> Window {
    Window::new(at(h1, m1), at(h2, m2)).expect("non-empty window")
}