morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::time::Timestamp Struct Reference

An optionally-empty timestamp field. More...

#include <datetime.hpp>

Public Member Functions

constexpr Timestamp () noexcept=default
 Constructs the empty state.
constexpr Timestamp (DateTime instant) noexcept
 Engages with instant.
constexpr Timestamp (std::optional< DateTime > payload) noexcept
 Adopts an optional payload as-is.
constexpr bool hasValue () const noexcept
 Whether an instant has been entered.
constexpr const DateTime & operator* () const noexcept
 Unchecked access to the engaged instant (UB when empty, exactly like std::optional — the unchecked contract is the point).
constexpr auto operator<=> (const Timestamp &other) const noexcept=default
 Ordering/equality on the payload; empty sorts before engaged.

Static Public Member Functions

static Timestamp now () noexcept
 An engaged timestamp holding the current UTC instant.

Public Attributes

std::optional< DateTime > value
 The payload; std::nullopt means "not entered".

Detailed Description

An optionally-empty timestamp field.

The blank state ("not entered / not recorded") lives inside, exactly like morph::units::Quantity: action structs never wrap a Timestamp in std::optional, and a non-optional Timestamp member is required by the morph::forms rules.

Definition at line 376 of file datetime.hpp.

Constructor & Destructor Documentation

◆ Timestamp() [1/2]

morph::time::Timestamp::Timestamp ( DateTime instant)
inlineconstexprnoexcept

Engages with instant.

Parameters
instantThe instant to hold.

Definition at line 385 of file datetime.hpp.

◆ Timestamp() [2/2]

morph::time::Timestamp::Timestamp ( std::optional< DateTime > payload)
inlineconstexprnoexcept

Adopts an optional payload as-is.

Parameters
payloadEngaged or empty payload.

Definition at line 389 of file datetime.hpp.

Member Function Documentation

◆ now()

Timestamp morph::time::Timestamp::now ( )
inlinestaticnodiscardnoexcept

An engaged timestamp holding the current UTC instant.

Returns
Timestamp{DateTime::now()}.

Definition at line 393 of file datetime.hpp.

◆ hasValue()

bool morph::time::Timestamp::hasValue ( ) const
inlinenodiscardconstexprnoexcept

Whether an instant has been entered.

Returns
true if the payload is engaged.

Definition at line 397 of file datetime.hpp.

◆ operator*()

const DateTime & morph::time::Timestamp::operator* ( ) const
inlinenodiscardconstexprnoexcept

Unchecked access to the engaged instant (UB when empty, exactly like std::optional — the unchecked contract is the point).

Returns
The engaged instant — a reference into this Timestamp, valid only for as long as it is.

Definition at line 404 of file datetime.hpp.

◆ operator<=>()

auto morph::time::Timestamp::operator<=> ( const Timestamp & other) const
nodiscardconstexprdefaultnoexcept

Ordering/equality on the payload; empty sorts before engaged.

Parameters
otherTimestamp to compare against.
Returns
The ordering of the two payloads.

Member Data Documentation

◆ value

std::optional<DateTime> morph::time::Timestamp::value

The payload; std::nullopt means "not entered".

Definition at line 378 of file datetime.hpp.


The documentation for this struct was generated from the following file: