ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
foresthub::platform::TimeInterface Class Referenceabstract

Abstract interface for time operations. More...

#include <time.hpp>

Public Member Functions

virtual std::string SyncTime (const TimeConfig &config={})=0
 Synchronize system time with an external source.
virtual unsigned long GetEpochTime () const =0
 Get current epoch time in seconds.
virtual unsigned long GetMillis () const =0
 Get milliseconds since startup (or arbitrary reference point).
virtual void Delay (unsigned long ms) const =0
 Delay execution for the specified number of milliseconds.
virtual bool IsSynced (unsigned long min_epoch=1767225600) const =0
 Check if time has been synchronized.
virtual void SetOffset (long std_offset_sec, int dst_offset_sec)=0
 Set timezone offset locally (no network I/O).
virtual long utc_offset_sec () const =0
 Get total UTC offset (standard + DST) in seconds.
unsigned long GetLocalEpoch () const
 Get current local epoch time (UTC + timezone offset) in seconds.
virtual void GetLocalTime (struct tm &result) const =0
 Get current local time as calendar fields (UTC + stored timezone offset).

Detailed Description

Abstract interface for time operations.

Member Function Documentation

◆ Delay()

virtual void foresthub::platform::TimeInterface::Delay ( unsigned long ms) const
pure virtual

Delay execution for the specified number of milliseconds.

Parameters
msDuration in milliseconds.

◆ GetEpochTime()

virtual unsigned long foresthub::platform::TimeInterface::GetEpochTime ( ) const
pure virtual

Get current epoch time in seconds.

Returns
Seconds since 1970-01-01 00:00:00 UTC (Unix epoch).

◆ GetLocalEpoch()

unsigned long foresthub::platform::TimeInterface::GetLocalEpoch ( ) const
inline

Get current local epoch time (UTC + timezone offset) in seconds.

Convenience method combining GetEpochTime() and utc_offset_sec().

Returns
Local epoch seconds. Safe for all real-world offsets (UTC-12 to UTC+14).

◆ GetLocalTime()

virtual void foresthub::platform::TimeInterface::GetLocalTime ( struct tm & result) const
pure virtual

Get current local time as calendar fields (UTC + stored timezone offset).

Parameters
resultOutput struct filled with local time fields.

◆ GetMillis()

virtual unsigned long foresthub::platform::TimeInterface::GetMillis ( ) const
pure virtual

Get milliseconds since startup (or arbitrary reference point).

Returns
Milliseconds elapsed; wraps after ~49.7 days on 32-bit platforms.

◆ IsSynced()

virtual bool foresthub::platform::TimeInterface::IsSynced ( unsigned long min_epoch = 1767225600) const
pure virtual

Check if time has been synchronized.

Parameters
min_epochMinimum epoch (seconds) to consider synced (default: 2026-01-01 00:00:00 UTC).
Returns
True if current epoch time is at or above min_epoch.

◆ SetOffset()

virtual void foresthub::platform::TimeInterface::SetOffset ( long std_offset_sec,
int dst_offset_sec )
pure virtual

Set timezone offset locally (no network I/O).

Overrides offset from SyncTime().

Parameters
std_offset_secTimezone standard offset from UTC in seconds (e.g., 3600 for CET).
dst_offset_secAdditional daylight saving offset in seconds (e.g., 3600 when active).

◆ SyncTime()

virtual std::string foresthub::platform::TimeInterface::SyncTime ( const TimeConfig & config = {})
pure virtual

Synchronize system time with an external source.

Parameters
configTime synchronization parameters (server, offsets, timeout).
Returns
Error message on failure, empty on success.

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