Abstract interface for time operations.
More...
#include <time.hpp>
|
| 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).
|
Abstract interface for time operations.
◆ Delay()
| virtual void foresthub::platform::TimeInterface::Delay |
( |
unsigned long | ms | ) |
const |
|
pure virtual |
Delay execution for the specified number of milliseconds.
- Parameters
-
| ms | Duration 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
-
| result | Output 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_epoch | Minimum 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_sec | Timezone standard offset from UTC in seconds (e.g., 3600 for CET). |
| dst_offset_sec | Additional 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
-
| config | Time synchronization parameters (server, offsets, timeout). |
- Returns
- Error message on failure, empty on success.
The documentation for this class was generated from the following file: