API — ICoreEssentials/Time
The public contract of 2 header(s) under src/ICoreEssentials/Time — 2 class/struct definition(s), 17 declaration(s). Each section shows the header's banner and its public (and protected-virtual) surface exactly as the file writes it.
| Header | Defines | Declarations | Bases |
|---|---|---|---|
ICoreDateTime.h | ICoreDateTime | 9 | — |
ICoreElapsedTimer.h | ICoreElapsedTimer | 8 | — |
ICoreDateTime.h#
src/ICoreEssentials/Time/ICoreDateTime.h
ICoreDateTime -- a wall-clock instant.
QT-FREE (phase 3). The member is milliseconds since the Unix epoch and this header names no Qt type; <QDate> is gone from the umbrella outright and <QDateTime> survives there only until ICorePath stops needing it (see the lastModified note below).
It passed the same test ICoreElapsedTimer did: B4 gave this wrapper NO conversion OUT, so nothing ever held a reference to the QDateTime and no signature promised it existed. The implicit constructor IN was the only pin, and it had exactly one claimant -- ICorePath::lastModified() -- which now calls fromMSecsSinceEpoch() explicitly instead.
BEHAVIOUR IS UNCHANGED on every point a call site can observe. Each was
ICoreDateTime#
ICoreDateTime.h:72 · class · pImpl · 9 declaration(s)
class ICoreDateTime {
public:
// Default-constructs INVALID, matching QDateTime. The runner's cache
// depends on it: a default-constructed `cachedStamp` must compare unequal
// to any real file mtime, so the first lookup always misses and populates.
ICoreDateTime();
~ICoreDateTime();
// An instant is a value and is copied as one. Written out because a
// unique_ptr<Impl> member deletes the implicit copy.
ICoreDateTime(const ICoreDateTime& other);
ICoreDateTime& operator=(const ICoreDateTime& other);
[[nodiscard]] static ICoreDateTime currentDateTime();
// How an instant from unmigrated Qt API becomes an ICoreDateTime. This
// replaces B4's implicit `ICoreDateTime(const QDateTime&)`; it is explicit
// and named because the epoch count it takes is not self-describing the way
// a QDateTime was, and because there is exactly one caller.
[[nodiscard]] static ICoreDateTime fromMSecsSinceEpoch(std::int64_t msecs);
// Qt's format syntax, minus the tokens listed in the header note. An
// invalid instant yields an empty string, as QDateTime does.
[[nodiscard]] ICoreString toString(const ICoreString& format) const;
// True when this instant falls on today's LOCAL date. Invalid is never
// today, matching `QDateTime().date() == QDate::currentDate()`.
[[nodiscard]] bool isToday() const;
[[nodiscard]] bool isValid() const noexcept;
// Hidden friends rather than free functions: they need the epoch count,
// and there is no call site for a public toMSecsSinceEpoch() to justify
// adding one (Rule 3). Declared here so ADL finds them, DEFINED in the
// .cpp.
//
// Equality only. The call site is a cache-invalidation check ("has this
// file's mtime changed"), which needs no ordering; QDateTime's relational
// operators have no call site in this project and so are not forwarded.
friend bool operator==(const ICoreDateTime& a, const ICoreDateTime& b) noexcept;
friend bool operator!=(const ICoreDateTime& a, const ICoreDateTime& b) noexcept;
private:
class Impl; // the two-line residue; state lives here
std::unique_ptr<Impl> impl;
};
ICoreElapsedTimer.h#
src/ICoreEssentials/Time/ICoreElapsedTimer.h
ICoreElapsedTimer#
ICoreElapsedTimer.h:66 · class · pImpl · 8 declaration(s)
ICoreElapsedTimer -- a monotonic stopwatch.
class ICoreElapsedTimer {
public:
ICoreElapsedTimer();
~ICoreElapsedTimer();
ICoreElapsedTimer(const ICoreElapsedTimer& other);
ICoreElapsedTimer& operator=(const ICoreElapsedTimer& other);
void start() noexcept;
void restart() noexcept;
[[nodiscard]] std::int64_t elapsed() const noexcept;
[[nodiscard]] bool isValid() const noexcept;
private:
class Impl; // the two-line residue; state lives here
std::unique_ptr<Impl> impl;
};