Skip to main content

QuarterHour

Struct QuarterHour 

Source
pub struct QuarterHour(/* private fields */);
Expand description

Fifteen minutes of real time, starting at an instant on a quarter-hour boundary.

Named by its start. See the module documentation for why, and for the conversion a market-facing adapter needs.

Written on the wire as the RFC 3339 spelling of its start, through crate::wire: time’s own serialisation is a nine-element array of its internal fields, which no partner can read and no version of time promises to keep.

Implementations§

Source§

impl QuarterHour

Source

pub const SECONDS: i64 = 900

Fifteen minutes, in seconds.

Source

pub const PERIODS_PER_ORDINARY_DAY: u32 = 96

How many periods a day has when nothing moves the clock — the number [PTB-A 50.7 §3.1.7.2] requires a meter to preserve across a synchronisation.

Nothing in the settlement grid counts to it: a grid built by adding fifteen minutes of real time needs no branch for a clock change, which is why emob_session::split has none. What the number is for is the question one layer out — how many Messperioden a given day actually has — and Self::periods_in_local_day answers that by walking the same grid rather than by returning this (D218).

Source

pub fn periods_in_local_day(zone: &TimeZone, date: Date) -> Option<u32>

How many settlement periods one local calendar day holds in a zone.

A quarter hour is fifteen minutes of real time and a local day is the span between two local midnights, so an ordinary day has Self::PERIODS_PER_ORDINARY_DAY, a spring-forward day 92 and an autumn-fold day 100. That is the number a balance-group submission is validated against [A6 §IV.1]: a series with 96 entries for 25 October is missing an hour of somebody’s balance group, and one with 96 for 29 March carries four periods that did not happen.

Measured between the two midnights rather than read from a table of transition dates, so a zone that shifts by half an hour, at an hour other than 02:00, or not at all needs no case.

None is an answer rather than an absence: the day is not a whole number of settlement periods, because a midnight does not land on the grid. Every civil offset in use today is a whole number of quarter hours — the fact emob_session::split relies on to have no daylight-saving branch — so it takes an offset like Liberia’s -00:44:30 before 1972 to reach, and returning 96 there would state a period count for a day that has none.

Source

pub fn containing(at: OffsetDateTime) -> QuarterHour

The quarter hour that contains at.

Source

pub fn is_boundary(at: OffsetDateTime) -> bool

Whether an instant falls exactly on a period boundary.

The question [PTB-A 50.7 §3.1.7.2] makes load-bearing for prices: “Ein Tarifwechsel ist erst mit dem Beginn der nächsten Messperiode durchzuführen.” A change that lands mid-period would put one settlement slot under two tariffs, which is a slot nobody can allocate and a price nobody can reproduce.

Source

pub fn boundary_at_or_after(at: OffsetDateTime) -> OffsetDateTime

The first period boundary at or after an instant.

What a tariff change that has to be aligned should be moved to: forward, never back, because a price may not start applying earlier than it was published.

Source

pub const fn start(self) -> OffsetDateTime

The instant this quarter hour begins.

Source

pub fn end(self) -> OffsetDateTime

The instant it ends, which is the next one’s start.

Source

pub fn metering_timestamp(self) -> OffsetDateTime

The timestamp German metrology and the market side label this period with — its end [PTB-A 50.7 §3.1.7.2].

The same instant as Self::end, under the name that says which convention is being spoken. An adapter writing an MSCONS load profile or handing a series to mako-emob calls this; everything inside this workspace uses Self::start. Reaching for the wrong one shifts every slot by fifteen minutes, which sums to zero and is wrong for every individual balance group.

Source

pub fn next(self) -> QuarterHour

The quarter hour after this one.

Trait Implementations§

Source§

impl Clone for QuarterHour

Source§

fn clone(&self) -> QuarterHour

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for QuarterHour

Source§

impl Debug for QuarterHour

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for QuarterHour

Available on crate feature serde only.
Source§

fn deserialize<D>( deserializer: D, ) -> Result<QuarterHour, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for QuarterHour

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

The period’s start, to the minute.

Source§

impl Eq for QuarterHour

Source§

impl Hash for QuarterHour

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for QuarterHour

Source§

fn cmp(&self, other: &QuarterHour) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for QuarterHour

Source§

fn eq(&self, other: &QuarterHour) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for QuarterHour

Source§

fn partial_cmp(&self, other: &QuarterHour) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for QuarterHour

Available on crate feature serde only.
Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for QuarterHour

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.