roo_time
API Documentation for roo_time
Loading...
Searching...
No Matches
roo_time Namespace Reference

Umbrella header for the roo_time module. More...

Namespaces

namespace  timezone
 

Data Structures

class  DateTime
 Represents wall time decomposed into date/time in a specific time zone. More...
 
class  Duration
 Represents an amount of time (e.g. 5s, 10min). More...
 
class  TimeZone
 
class  Uptime
 Represents an instant relative to process/boot start time. More...
 
class  WallTime
 Represents absolute wall time since Unix epoch. More...
 
class  WallTimeClock
 Abstract interface for obtaining current wall time. More...
 

Typedefs

using Interval = Duration
 Backwards compatibility alias. Prefer Duration in new code.
 

Enumerations

enum  DayOfWeek {
  kSunday = 0 , kMonday = 1 , kTuesday = 2 , kWednesday = 3 ,
  kThursday = 4 , kFriday = 5 , kSaturday = 6
}
 
enum  Month {
  kJanuary = 1 , kFebruary = 2 , kMarch = 3 , kApril = 4 ,
  kMay = 5 , kJune = 6 , kJuly = 7 , kAugust = 8 ,
  kSeptember = 9 , kOctober = 10 , kNovember = 11 , kDecember = 12
}
 

Functions

constexpr Duration Micros (long long micros)
 Constructs a duration from microseconds.
 
constexpr Duration Millis (long long millis)
 Constructs a duration from milliseconds.
 
constexpr Duration Millis (unsigned long long millis)
 
constexpr Duration Millis (long millis)
 
constexpr Duration Millis (unsigned long millis)
 
constexpr Duration Millis (int millis)
 
constexpr Duration Millis (unsigned int millis)
 
constexpr Duration Millis (short millis)
 
constexpr Duration Millis (unsigned short millis)
 
constexpr Duration Millis (float millis)
 
constexpr Duration Millis (double millis)
 
constexpr Duration Seconds (long long seconds)
 Constructs a duration from seconds.
 
constexpr Duration Seconds (unsigned long long seconds)
 
constexpr Duration Seconds (long seconds)
 
constexpr Duration Seconds (unsigned long seconds)
 
constexpr Duration Seconds (int seconds)
 
constexpr Duration Seconds (unsigned int seconds)
 
constexpr Duration Seconds (short seconds)
 
constexpr Duration Seconds (unsigned short seconds)
 
constexpr Duration Seconds (float seconds)
 
constexpr Duration Seconds (double seconds)
 
constexpr Duration Minutes (long long minutes)
 Constructs a duration from minutes.
 
constexpr Duration Minutes (unsigned long long minutes)
 
constexpr Duration Minutes (long minutes)
 
constexpr Duration Minutes (unsigned long minutes)
 
constexpr Duration Minutes (int minutes)
 
constexpr Duration Minutes (unsigned int minutes)
 
constexpr Duration Minutes (short minutes)
 
constexpr Duration Minutes (unsigned short minutes)
 
constexpr Duration Minutes (float minutes)
 
constexpr Duration Minutes (double minutes)
 
constexpr Duration Hours (long long hours)
 Constructs a duration from hours.
 
constexpr Duration Hours (unsigned long long minutes)
 
constexpr Duration Hours (long minutes)
 
constexpr Duration Hours (unsigned long minutes)
 
constexpr Duration Hours (int minutes)
 
constexpr Duration Hours (unsigned int minutes)
 
constexpr Duration Hours (short minutes)
 
constexpr Duration Hours (unsigned short minutes)
 
constexpr Duration Hours (float hours)
 
constexpr Duration Hours (double hours)
 
bool operator== (const Duration &a, const Duration &b)
 Returns true if both durations are equal.
 
bool operator!= (const Duration &a, const Duration &b)
 Returns true if durations differ.
 
bool operator< (const Duration &a, const Duration &b)
 Returns true if a is shorter than b.
 
bool operator> (const Duration &a, const Duration &b)
 Returns true if a is longer than b.
 
bool operator<= (const Duration &a, const Duration &b)
 Returns true if a is not longer than b.
 
bool operator>= (const Duration &a, const Duration &b)
 Returns true if a is not shorter than b.
 
Duration operator+ (const Duration &a, const Duration &b)
 Returns the sum of two durations.
 
Duration operator- (const Duration &a, const Duration &b)
 Returns the difference between two durations.
 
Duration operator* (const Duration &a, int b)
 Multiplies duration by an integer factor.
 
Duration operator* (int a, const Duration &b)
 Multiplies duration by an integer factor.
 
bool operator== (const Uptime &a, const Uptime &b)
 Returns true if uptimes are equal.
 
bool operator!= (const Uptime &a, const Uptime &b)
 Returns true if uptimes differ.
 
bool operator< (const Uptime &a, const Uptime &b)
 Returns true if a is earlier than b.
 
bool operator> (const Uptime &a, const Uptime &b)
 Returns true if a is later than b.
 
bool operator<= (const Uptime &a, const Uptime &b)
 Returns true if a is not later than b.
 
bool operator>= (const Uptime &a, const Uptime &b)
 Returns true if a is not earlier than b.
 
Duration operator- (const Uptime &a, const Uptime &b)
 Returns elapsed duration between two uptime instants.
 
Uptime operator+ (const Uptime &u, const Duration &i)
 Returns uptime shifted by duration.
 
Uptime operator- (const Uptime &u, const Duration &i)
 Returns uptime shifted backwards by duration.
 
Uptime operator+ (const Duration &i, const Uptime &u)
 Returns uptime shifted by duration.
 
void Delay (Duration duration)
 Delays execution for duration.
 
void DelayUntil (Uptime deadline)
 Delays execution until deadline.
 
bool operator== (const WallTime &a, const WallTime &b)
 Returns true if both wall times are equal.
 
bool operator!= (const WallTime &a, const WallTime &b)
 Returns true if wall times differ.
 
bool operator< (const WallTime &a, const WallTime &b)
 Returns true if a is earlier than b.
 
bool operator> (const WallTime &a, const WallTime &b)
 Returns true if a is later than b.
 
bool operator<= (const WallTime &a, const WallTime &b)
 Returns true if a is not later than b.
 
bool operator>= (const WallTime &a, const WallTime &b)
 Returns true if a is not earlier than b.
 
Duration operator- (const WallTime &a, const WallTime &b)
 Returns elapsed duration between two wall times.
 
WallTime operator+ (const WallTime &t, const Duration &i)
 Returns wall time shifted by duration.
 
WallTime operator- (const WallTime &t, const Duration &i)
 Returns wall time shifted backwards by duration.
 
WallTime operator+ (const Duration &i, const WallTime &t)
 Returns wall time shifted by duration.
 
bool operator== (const DateTime &a, const DateTime &b)
 Returns true if both date-times represent the same instant and offset.
 
bool operator!= (const DateTime &a, const DateTime &b)
 Returns true if date-times differ in instant or time-zone offset.
 

Variables

static int64_t last_reading = 0
 
static int64_t offset = 0
 

Detailed Description

Umbrella header for the roo_time module.

Provides duration, uptime, and wall-time abstractions. Convenience classes for handling delays and elapsed time measurement.

Helps avoid common mistakes such as mixing time units or confusing timestamps with durations.

Typedef Documentation

◆ Interval

using roo_time::Interval = typedef Duration

Backwards compatibility alias. Prefer Duration in new code.

Definition at line 213 of file roo_time.h.

Enumeration Type Documentation

◆ DayOfWeek

Enumerator
kSunday 
kMonday 
kTuesday 
kWednesday 
kThursday 
kFriday 
kSaturday 

Definition at line 707 of file roo_time.h.

◆ Month

Enumerator
kJanuary 
kFebruary 
kMarch 
kApril 
kMay 
kJune 
kJuly 
kAugust 
kSeptember 
kOctober 
kNovember 
kDecember 

Definition at line 717 of file roo_time.h.

Function Documentation

◆ Delay()

void IRAM_ATTR roo_time::Delay ( Duration  duration)

Delays execution for duration.

Negative durations are treated as no-op.

Definition at line 133 of file uptime_now.cpp.

References roo_time::Duration::inMicros().

Referenced by DelayUntil().

◆ DelayUntil()

void IRAM_ATTR roo_time::DelayUntil ( Uptime  deadline)

Delays execution until deadline.

If deadline is in the past, returns immediately.

Definition at line 134 of file uptime_now.cpp.

References Delay(), and roo_time::Uptime::Now().

◆ Hours() [1/10]

constexpr Duration roo_time::Hours ( double  hours)
inlineconstexpr

Definition at line 386 of file roo_time.h.

◆ Hours() [2/10]

constexpr Duration roo_time::Hours ( float  hours)
inlineconstexpr

Definition at line 382 of file roo_time.h.

◆ Hours() [3/10]

constexpr Duration roo_time::Hours ( int  minutes)
inlineconstexpr

Definition at line 366 of file roo_time.h.

References Hours().

◆ Hours() [4/10]

constexpr Duration roo_time::Hours ( long long  hours)
inlineconstexpr

Constructs a duration from hours.

Overloads accept integer and floating-point input types.

Definition at line 350 of file roo_time.h.

Referenced by Hours(), Hours(), Hours(), Hours(), Hours(), Hours(), and Hours().

◆ Hours() [5/10]

constexpr Duration roo_time::Hours ( long  minutes)
inlineconstexpr

Definition at line 358 of file roo_time.h.

References Hours().

◆ Hours() [6/10]

constexpr Duration roo_time::Hours ( short  minutes)
inlineconstexpr

Definition at line 374 of file roo_time.h.

References Hours().

◆ Hours() [7/10]

constexpr Duration roo_time::Hours ( unsigned int  minutes)
inlineconstexpr

Definition at line 370 of file roo_time.h.

References Hours().

◆ Hours() [8/10]

constexpr Duration roo_time::Hours ( unsigned long long  minutes)
inlineconstexpr

Definition at line 354 of file roo_time.h.

References Hours().

◆ Hours() [9/10]

constexpr Duration roo_time::Hours ( unsigned long  minutes)
inlineconstexpr

Definition at line 362 of file roo_time.h.

References Hours().

◆ Hours() [10/10]

constexpr Duration roo_time::Hours ( unsigned short  minutes)
inlineconstexpr

Definition at line 378 of file roo_time.h.

References Hours().

◆ Micros()

constexpr Duration roo_time::Micros ( long long  micros)
inlineconstexpr

Constructs a duration from microseconds.

Definition at line 216 of file roo_time.h.

Referenced by roo_time::DateTime::DateTime(), operator*(), operator*(), operator+(), operator-(), and operator-().

◆ Millis() [1/10]

constexpr Duration roo_time::Millis ( double  millis)
inlineconstexpr

Definition at line 257 of file roo_time.h.

◆ Millis() [2/10]

constexpr Duration roo_time::Millis ( float  millis)
inlineconstexpr

Definition at line 253 of file roo_time.h.

◆ Millis() [3/10]

constexpr Duration roo_time::Millis ( int  millis)
inlineconstexpr

Definition at line 237 of file roo_time.h.

References Millis().

◆ Millis() [4/10]

constexpr Duration roo_time::Millis ( long long  millis)
inlineconstexpr

Constructs a duration from milliseconds.

Overloads accept integer and floating-point input types.

Definition at line 221 of file roo_time.h.

Referenced by Millis(), Millis(), Millis(), Millis(), Millis(), Millis(), and Millis().

◆ Millis() [5/10]

constexpr Duration roo_time::Millis ( long  millis)
inlineconstexpr

Definition at line 229 of file roo_time.h.

References Millis().

◆ Millis() [6/10]

constexpr Duration roo_time::Millis ( short  millis)
inlineconstexpr

Definition at line 245 of file roo_time.h.

References Millis().

◆ Millis() [7/10]

constexpr Duration roo_time::Millis ( unsigned int  millis)
inlineconstexpr

Definition at line 241 of file roo_time.h.

References Millis().

◆ Millis() [8/10]

constexpr Duration roo_time::Millis ( unsigned long long  millis)
inlineconstexpr

Definition at line 225 of file roo_time.h.

References Millis().

◆ Millis() [9/10]

constexpr Duration roo_time::Millis ( unsigned long  millis)
inlineconstexpr

Definition at line 233 of file roo_time.h.

References Millis().

◆ Millis() [10/10]

constexpr Duration roo_time::Millis ( unsigned short  millis)
inlineconstexpr

Definition at line 249 of file roo_time.h.

References Millis().

◆ Minutes() [1/10]

constexpr Duration roo_time::Minutes ( double  minutes)
inlineconstexpr

Definition at line 343 of file roo_time.h.

◆ Minutes() [2/10]

constexpr Duration roo_time::Minutes ( float  minutes)
inlineconstexpr

Definition at line 339 of file roo_time.h.

◆ Minutes() [3/10]

constexpr Duration roo_time::Minutes ( int  minutes)
inlineconstexpr

Definition at line 323 of file roo_time.h.

References Minutes().

◆ Minutes() [4/10]

constexpr Duration roo_time::Minutes ( long long  minutes)
inlineconstexpr

Constructs a duration from minutes.

Overloads accept integer and floating-point input types.

Definition at line 307 of file roo_time.h.

Referenced by Minutes(), Minutes(), Minutes(), Minutes(), Minutes(), Minutes(), Minutes(), and roo_time::TimeZone::offset().

◆ Minutes() [5/10]

constexpr Duration roo_time::Minutes ( long  minutes)
inlineconstexpr

Definition at line 315 of file roo_time.h.

References Minutes().

◆ Minutes() [6/10]

constexpr Duration roo_time::Minutes ( short  minutes)
inlineconstexpr

Definition at line 331 of file roo_time.h.

References Minutes().

◆ Minutes() [7/10]

constexpr Duration roo_time::Minutes ( unsigned int  minutes)
inlineconstexpr

Definition at line 327 of file roo_time.h.

References Minutes().

◆ Minutes() [8/10]

constexpr Duration roo_time::Minutes ( unsigned long long  minutes)
inlineconstexpr

Definition at line 311 of file roo_time.h.

References Minutes().

◆ Minutes() [9/10]

constexpr Duration roo_time::Minutes ( unsigned long  minutes)
inlineconstexpr

Definition at line 319 of file roo_time.h.

References Minutes().

◆ Minutes() [10/10]

constexpr Duration roo_time::Minutes ( unsigned short  minutes)
inlineconstexpr

Definition at line 335 of file roo_time.h.

References Minutes().

◆ operator!=() [1/4]

bool roo_time::operator!= ( const DateTime a,
const DateTime b 
)
inline

Returns true if date-times differ in instant or time-zone offset.

Definition at line 837 of file roo_time.h.

References roo_time::TimeZone::offset(), roo_time::DateTime::timeZone(), and roo_time::DateTime::wallTime().

◆ operator!=() [2/4]

bool roo_time::operator!= ( const Duration a,
const Duration b 
)
inline

Returns true if durations differ.

Definition at line 396 of file roo_time.h.

References roo_time::Duration::inMicros().

◆ operator!=() [3/4]

bool roo_time::operator!= ( const Uptime a,
const Uptime b 
)
inline

Returns true if uptimes differ.

Definition at line 523 of file roo_time.h.

References roo_time::Uptime::inMicros().

◆ operator!=() [4/4]

bool roo_time::operator!= ( const WallTime a,
const WallTime b 
)
inline

Returns true if wall times differ.

Definition at line 618 of file roo_time.h.

References roo_time::WallTime::sinceEpoch().

◆ operator*() [1/2]

Duration roo_time::operator* ( const Duration a,
int  b 
)
inline

Multiplies duration by an integer factor.

Definition at line 431 of file roo_time.h.

References roo_time::Duration::inMicros(), and Micros().

◆ operator*() [2/2]

Duration roo_time::operator* ( int  a,
const Duration b 
)
inline

Multiplies duration by an integer factor.

Definition at line 436 of file roo_time.h.

References roo_time::Duration::inMicros(), and Micros().

◆ operator+() [1/5]

Duration roo_time::operator+ ( const Duration a,
const Duration b 
)
inline

Returns the sum of two durations.

Definition at line 421 of file roo_time.h.

References roo_time::Duration::inMicros(), and Micros().

◆ operator+() [2/5]

Uptime roo_time::operator+ ( const Duration i,
const Uptime u 
)
inline

Returns uptime shifted by duration.

Definition at line 563 of file roo_time.h.

◆ operator+() [3/5]

WallTime roo_time::operator+ ( const Duration i,
const WallTime t 
)
inline

Returns wall time shifted by duration.

Definition at line 658 of file roo_time.h.

◆ operator+() [4/5]

Uptime roo_time::operator+ ( const Uptime u,
const Duration i 
)
inline

Returns uptime shifted by duration.

Definition at line 553 of file roo_time.h.

◆ operator+() [5/5]

WallTime roo_time::operator+ ( const WallTime t,
const Duration i 
)
inline

Returns wall time shifted by duration.

Definition at line 648 of file roo_time.h.

◆ operator-() [1/5]

Duration roo_time::operator- ( const Duration a,
const Duration b 
)
inline

Returns the difference between two durations.

Definition at line 426 of file roo_time.h.

References roo_time::Duration::inMicros(), and Micros().

◆ operator-() [2/5]

Duration roo_time::operator- ( const Uptime a,
const Uptime b 
)
inline

Returns elapsed duration between two uptime instants.

Definition at line 548 of file roo_time.h.

References roo_time::Uptime::inMicros(), and Micros().

◆ operator-() [3/5]

Uptime roo_time::operator- ( const Uptime u,
const Duration i 
)
inline

Returns uptime shifted backwards by duration.

Definition at line 558 of file roo_time.h.

◆ operator-() [4/5]

Duration roo_time::operator- ( const WallTime a,
const WallTime b 
)
inline

Returns elapsed duration between two wall times.

Definition at line 643 of file roo_time.h.

References roo_time::WallTime::sinceEpoch().

◆ operator-() [5/5]

WallTime roo_time::operator- ( const WallTime t,
const Duration i 
)
inline

Returns wall time shifted backwards by duration.

Definition at line 653 of file roo_time.h.

◆ operator<() [1/3]

bool roo_time::operator< ( const Duration a,
const Duration b 
)
inline

Returns true if a is shorter than b.

Definition at line 401 of file roo_time.h.

References roo_time::Duration::inMicros().

◆ operator<() [2/3]

bool roo_time::operator< ( const Uptime a,
const Uptime b 
)
inline

Returns true if a is earlier than b.

Definition at line 528 of file roo_time.h.

References roo_time::Uptime::inMicros().

◆ operator<() [3/3]

bool roo_time::operator< ( const WallTime a,
const WallTime b 
)
inline

Returns true if a is earlier than b.

Definition at line 623 of file roo_time.h.

References roo_time::WallTime::sinceEpoch().

◆ operator<=() [1/3]

bool roo_time::operator<= ( const Duration a,
const Duration b 
)
inline

Returns true if a is not longer than b.

Definition at line 411 of file roo_time.h.

References roo_time::Duration::inMicros().

◆ operator<=() [2/3]

bool roo_time::operator<= ( const Uptime a,
const Uptime b 
)
inline

Returns true if a is not later than b.

Definition at line 538 of file roo_time.h.

References roo_time::Uptime::inMicros().

◆ operator<=() [3/3]

bool roo_time::operator<= ( const WallTime a,
const WallTime b 
)
inline

Returns true if a is not later than b.

Definition at line 633 of file roo_time.h.

References roo_time::WallTime::sinceEpoch().

◆ operator==() [1/4]

bool roo_time::operator== ( const DateTime a,
const DateTime b 
)
inline

Returns true if both date-times represent the same instant and offset.

Definition at line 831 of file roo_time.h.

References roo_time::TimeZone::offset(), roo_time::DateTime::timeZone(), and roo_time::DateTime::wallTime().

◆ operator==() [2/4]

bool roo_time::operator== ( const Duration a,
const Duration b 
)
inline

Returns true if both durations are equal.

Definition at line 391 of file roo_time.h.

References roo_time::Duration::inMicros().

◆ operator==() [3/4]

bool roo_time::operator== ( const Uptime a,
const Uptime b 
)
inline

Returns true if uptimes are equal.

Definition at line 518 of file roo_time.h.

References roo_time::Uptime::inMicros().

◆ operator==() [4/4]

bool roo_time::operator== ( const WallTime a,
const WallTime b 
)
inline

Returns true if both wall times are equal.

Definition at line 613 of file roo_time.h.

References roo_time::WallTime::sinceEpoch().

◆ operator>() [1/3]

bool roo_time::operator> ( const Duration a,
const Duration b 
)
inline

Returns true if a is longer than b.

Definition at line 406 of file roo_time.h.

References roo_time::Duration::inMicros().

◆ operator>() [2/3]

bool roo_time::operator> ( const Uptime a,
const Uptime b 
)
inline

Returns true if a is later than b.

Definition at line 533 of file roo_time.h.

References roo_time::Uptime::inMicros().

◆ operator>() [3/3]

bool roo_time::operator> ( const WallTime a,
const WallTime b 
)
inline

Returns true if a is later than b.

Definition at line 628 of file roo_time.h.

References roo_time::WallTime::sinceEpoch().

◆ operator>=() [1/3]

bool roo_time::operator>= ( const Duration a,
const Duration b 
)
inline

Returns true if a is not shorter than b.

Definition at line 416 of file roo_time.h.

References roo_time::Duration::inMicros().

◆ operator>=() [2/3]

bool roo_time::operator>= ( const Uptime a,
const Uptime b 
)
inline

Returns true if a is not earlier than b.

Definition at line 543 of file roo_time.h.

References roo_time::Uptime::inMicros().

◆ operator>=() [3/3]

bool roo_time::operator>= ( const WallTime a,
const WallTime b 
)
inline

Returns true if a is not earlier than b.

Definition at line 638 of file roo_time.h.

References roo_time::WallTime::sinceEpoch().

◆ Seconds() [1/10]

constexpr Duration roo_time::Seconds ( double  seconds)
inlineconstexpr

Definition at line 300 of file roo_time.h.

◆ Seconds() [2/10]

constexpr Duration roo_time::Seconds ( float  seconds)
inlineconstexpr

Definition at line 296 of file roo_time.h.

◆ Seconds() [3/10]

constexpr Duration roo_time::Seconds ( int  seconds)
inlineconstexpr

Definition at line 280 of file roo_time.h.

References Seconds().

◆ Seconds() [4/10]

constexpr Duration roo_time::Seconds ( long long  seconds)
inlineconstexpr

Constructs a duration from seconds.

Overloads accept integer and floating-point input types.

Definition at line 264 of file roo_time.h.

Referenced by Seconds(), Seconds(), Seconds(), Seconds(), Seconds(), Seconds(), and Seconds().

◆ Seconds() [5/10]

constexpr Duration roo_time::Seconds ( long  seconds)
inlineconstexpr

Definition at line 272 of file roo_time.h.

References Seconds().

◆ Seconds() [6/10]

constexpr Duration roo_time::Seconds ( short  seconds)
inlineconstexpr

Definition at line 288 of file roo_time.h.

References Seconds().

◆ Seconds() [7/10]

constexpr Duration roo_time::Seconds ( unsigned int  seconds)
inlineconstexpr

Definition at line 284 of file roo_time.h.

References Seconds().

◆ Seconds() [8/10]

constexpr Duration roo_time::Seconds ( unsigned long long  seconds)
inlineconstexpr

Definition at line 268 of file roo_time.h.

References Seconds().

◆ Seconds() [9/10]

constexpr Duration roo_time::Seconds ( unsigned long  seconds)
inlineconstexpr

Definition at line 276 of file roo_time.h.

References Seconds().

◆ Seconds() [10/10]

constexpr Duration roo_time::Seconds ( unsigned short  seconds)
inlineconstexpr

Definition at line 292 of file roo_time.h.

References Seconds().

Variable Documentation

◆ last_reading

int64_t roo_time::last_reading = 0
static

Definition at line 115 of file uptime_now.cpp.

Referenced by roo_time::Uptime::Now().

◆ offset

int64_t roo_time::offset = 0
static

Definition at line 118 of file uptime_now.cpp.

Referenced by roo_time::Uptime::Now().